first commit

This commit is contained in:
2025-08-02 16:30:27 +02:00
commit 23646bfcee
14851 changed files with 1750626 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
{
"reclamations_elnino": [
{
"id": 100,
"code": "R100",
"date_created": "2019-04-11 08:12:08",
"date_accepted": null,
"date_handle": null,
"status": 0,
"name": "Ondřej",
"surname": "Beneš",
"street": "Úpická 337",
"city": "Malé Svatoňovice",
"zip": "54234",
"phone": "+420702089098",
"bank_account": "123-000055515231/0800",
"history": "[{\"comment\":\"Nefouka to\",\"status\":0,\"date\":\"2019-04-11 08:12:08\",\"notified\":0,\"custom_data\":[],\"admin\":null}]"
}
]
}

View File

@@ -0,0 +1,109 @@
<?php
namespace KupShop\ReclamationsElninoBundle\Tests;
use KupShop\DevelopmentBundle\MailArchive;
use KupShop\ReclamationsElninoBundle\Util\ReclamationsUtil;
class ReclamationsElninoTest extends \DatabaseTestCase
{
/** @var ReclamationsUtil */
private $reclamations;
/** @var MailArchive */
private $mailArchive;
public static function setUpBeforeClass(): void
{
if (!findModule('reclamations_elnino')) {
self::markTestSkipped('Modul reclamations_elnino není zapnutý.');
}
}
protected function setUp(): void
{
parent::setUp();
$this->reclamations = $this->get(ReclamationsUtil::class);
$this->mailArchive = $this->get(MailArchive::class);
}
public function testCreateAndGetReclamation()
{
$reclamationId = $this->reclamations->createReclamation([34 => 1], 1, [], '123-4561315454/0800', null, 'User note');
$reclamation = $this->reclamations->getReclamation($reclamationId);
$this->assertRegExp('/R\d{3}/', $reclamation->getCode());
$history = $reclamation->getHistory();
$history = reset($history);
$this->assertEquals('User note', $history['comment']);
}
public function testEmailSentOnReturnCreated()
{
$dbcfg = \Settings::getDefault();
$dbcfg->reclamations['descr'] = '{KOD_REKLAMACE}';
$this->reclamations->createReclamation([34 => 1], 1, [], '123-4561315454/0800', 'User note');
$email = $this->mailArchive->getLast();
$this->assertNotEmpty($email);
$this->assertRegExp('/Demo - Přijali jsme formulář s reklamací R\d{3}/', $email['subject']);
}
public function testGetEmails()
{
$contents = $this->reclamations->getEmails();
$this->assertNotEmpty($contents);
}
public function testLogAndGetHistory()
{
$this->reclamations->logHistory(100, 'Log history test');
$history = $this->reclamations->getHistory(100);
$last = end($history);
unset($last['date']);
$this->assertEquals($last, [
'comment' => 'Log history test',
'status' => 0,
'notified' => 0,
'custom_data' => [],
'admin' => null,
'status_name' => 'Nová',
'admin_name' => null,
]);
}
public function testChangeStatus()
{
$reclamation = $this->reclamations->getReclamation(100);
$this->assertEquals(0, $reclamation->getStatus());
$this->assertEmpty($reclamation->getDateAccepted());
$this->assertEmpty($reclamation->getDateHandle());
$this->reclamations->changeStatus(100, 1);
$reclamation = $this->reclamations->getReclamation(100);
$this->assertEquals(1, $reclamation->getStatus());
$this->assertNotEmpty($reclamation->getDateAccepted());
$this->assertEmpty($reclamation->getDateHandle());
$this->reclamations->changeStatus(100, 2);
$reclamation = $this->reclamations->getReclamation(100);
$this->assertEquals(2, $reclamation->getStatus());
$this->assertNotEmpty($reclamation->getDateAccepted());
$this->assertNotEmpty($reclamation->getDateHandle());
$this->assertTrue($reclamation->isClosed());
}
protected function getDataSet()
{
return $this->getJsonDataSetFromFile();
}
}