2025-08-09 21:07:39 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace CakeAccounting\Test\TestCase\Controller;
|
|
|
|
|
|
|
|
use Cake\ORM\Table;
|
|
|
|
use CakeAccounting\Controller\DeJournalItemsController;
|
|
|
|
use CakeAccounting\Model\Table\DeAccountsTable;
|
|
|
|
use CakeAccounting\Model\Table\DeJournalItemsTable;
|
2025-08-09 22:12:04 +00:00
|
|
|
use CakeAccounting\Model\Table\DeJournalsTable;
|
2025-08-09 21:07:39 +00:00
|
|
|
use PHPUnit\Exception;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CakeAccounting\Controller\DeJournalItemsController Test Case
|
|
|
|
*
|
|
|
|
* @uses DeJournalItemsController
|
|
|
|
*/
|
|
|
|
class DeJournalItemsControllerTest extends BaseControllerTest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var DeAccountsTable|Table
|
|
|
|
*/
|
|
|
|
protected DeAccountsTable|Table $DeAccounts;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var DeJournalItemsTable|Table
|
|
|
|
*/
|
|
|
|
protected DeJournalItemsTable|Table $DeJournalItems;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fixtures
|
|
|
|
*
|
|
|
|
* @var array<string>
|
|
|
|
*/
|
|
|
|
protected array $fixtures = [
|
|
|
|
'plugin.CakeAccounting.DeJournals',
|
|
|
|
'plugin.CakeAccounting.DeJournalEntries',
|
|
|
|
'plugin.CakeAccounting.DeJournalItems',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* setUp method
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
2025-08-09 22:12:04 +00:00
|
|
|
// $this->enableCsrfToken();
|
|
|
|
// $this->enableSecurityToken();
|
|
|
|
$this->disableErrorHandlerMiddleware();
|
|
|
|
$config = $this->getTableLocator()->exists('DeAccounts') ? [] : ['className' => DeAccountsTable::class];
|
|
|
|
$this->DeAccounts = $this->getTableLocator()->get('DeAccounts', $config);
|
|
|
|
|
|
|
|
$config = $this->getTableLocator()->exists('DeJournalItems') ? [] : ['className' => DeJournalItemsTable::class];
|
|
|
|
$this->DeJournalItems = $this->getTableLocator()->get('DeJournalItems', $config);
|
2025-08-09 21:07:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* tearDown method
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function tearDown(): void
|
|
|
|
{
|
|
|
|
unset($this->DeJournalItems);
|
|
|
|
|
|
|
|
parent::tearDown();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test index method
|
|
|
|
*
|
|
|
|
* Tests the index action with a logged in user
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @throws Exception
|
|
|
|
*
|
|
|
|
* @uses DeJournalItemsController::index
|
|
|
|
*/
|
|
|
|
public function testIndexGetLoggedIn(): void
|
|
|
|
{
|
2025-08-09 22:12:04 +00:00
|
|
|
//$this->loginUserByRole('admin');
|
2025-08-09 21:07:39 +00:00
|
|
|
$url = [
|
|
|
|
'plugin' => 'CakeAccounting',
|
|
|
|
'controller' => 'DeJournalItems',
|
|
|
|
'action' => 'index',
|
|
|
|
];
|
|
|
|
$this->get($url);
|
|
|
|
$this->assertResponseCode(200);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test view method
|
|
|
|
*
|
|
|
|
* Tests the view action with a logged in user
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @throws Exception
|
|
|
|
*
|
|
|
|
* @uses DeJournalItemsController::view
|
|
|
|
*/
|
|
|
|
public function testViewGetLoggedIn(): void
|
|
|
|
{
|
|
|
|
$id = 1;
|
2025-08-09 22:12:04 +00:00
|
|
|
//$this->loginUserByRole('admin');
|
2025-08-09 21:07:39 +00:00
|
|
|
$url = [
|
|
|
|
'plugin' => 'CakeAccounting',
|
|
|
|
'controller' => 'DeJournalItems',
|
|
|
|
'action' => 'view',
|
|
|
|
$id,
|
|
|
|
];
|
|
|
|
$this->get($url);
|
|
|
|
$this->assertResponseCode(200);
|
|
|
|
}
|
|
|
|
}
|