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,102 @@
<?php
namespace KupShop\ReclamationsBundle\Tests;
use KupShop\DevelopmentBundle\MailArchive;
use KupShop\ReclamationsBundle\Util\ReclamationsUtil;
class ReclamationsTest extends \DatabaseTestCase
{
/** @var ReclamationsUtil */
private $reclamations;
/** @var MailArchive */
private $mailArchive;
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, [], '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, [], '123-4561315454/0800', 'User note');
$email = $this->mailArchive->getLast();
$this->assertNotEmpty($email);
$this->assertRegExp('/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();
}
}