148 lines
3.6 KiB
PHP
148 lines
3.6 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace CakeAccounting\Test\TestCase\Controller;
|
|
|
|
use Cake\ORM\Table;
|
|
use Cake\TestSuite\IntegrationTestTrait;
|
|
use Cake\TestSuite\TestCase;
|
|
use CakeAccounting\Controller\DeExternalAccountStatementsController;
|
|
use CakeAccounting\Model\Table\DeExternalAccountStatementsTable;
|
|
use PHPUnit\Exception;
|
|
|
|
/**
|
|
* CakeAccounting\Controller\DeExternalAccountStatementsController Test Case
|
|
*
|
|
* @uses DeExternalAccountStatementsController
|
|
*/
|
|
class DeExternalAccountStatementsControllerTest extends BaseControllerTest
|
|
{
|
|
/**
|
|
* @var DeExternalAccountStatementsTable|Table
|
|
*/
|
|
protected DeExternalAccountStatementsTable|Table $DeExternalAccountStatements;
|
|
/**
|
|
* Fixtures
|
|
*
|
|
* @var array<string>
|
|
*/
|
|
protected array $fixtures = [
|
|
'plugin.CakeAccounting.DeExternalAccountStatements',
|
|
];
|
|
|
|
/**
|
|
* setUp method
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->DeExternalAccountStatements = $this->getTableLocator()->get('DeExternalAccountStatements');
|
|
}
|
|
|
|
/**
|
|
* tearDown method
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function tearDown(): void
|
|
{
|
|
unset($this->DeExternalAccountStatements);
|
|
|
|
parent::tearDown();
|
|
}
|
|
|
|
/**
|
|
* Test index method
|
|
*
|
|
* Tests the index action with an unauthenticated user (not logged in)
|
|
*
|
|
* @return void
|
|
* @throws Exception
|
|
*
|
|
* @uses DeExternalAccountStatementsController::index
|
|
*/
|
|
public function testIndexGetUnauthenticated(): void
|
|
{
|
|
$url = [
|
|
'plugin' => 'CakeAccounting',
|
|
'controller' => 'DeExternalAccountStatements',
|
|
'action' => 'index',
|
|
];
|
|
$this->get($url);
|
|
$this->assertResponseCode(302);
|
|
$this->assertRedirectContains('login');
|
|
}
|
|
|
|
/**
|
|
* Test index method
|
|
*
|
|
* Tests the index action with a logged in user
|
|
*
|
|
* @return void
|
|
* @throws Exception
|
|
*
|
|
* @uses DeExternalAccountStatementsController::index
|
|
*/
|
|
public function testIndexGetLoggedIn(): void
|
|
{
|
|
$this->loginUserByRole('admin');
|
|
$url = [
|
|
'plugin' => 'CakeAccounting',
|
|
'controller' => 'DeExternalAccountStatements',
|
|
'action' => 'index',
|
|
];
|
|
$this->get($url);
|
|
$this->assertResponseCode(200);
|
|
}
|
|
|
|
/**
|
|
* Test view method
|
|
*
|
|
* Tests the view action with an unauthenticated user (not logged in)
|
|
*
|
|
* @return void
|
|
* @throws Exception
|
|
*
|
|
* @uses DeExternalAccountStatementsController::view
|
|
*/
|
|
public function testViewGetUnauthenticated(): void
|
|
{
|
|
$id = '2f83162b-2bec-4826-8853-fbda2fac3a95';
|
|
$url = [
|
|
'plugin' => 'CakeAccounting',
|
|
'controller' => 'DeExternalAccountStatements',
|
|
'action' => 'view',
|
|
$id,
|
|
];
|
|
$this->get($url);
|
|
$this->assertResponseCode(302);
|
|
$this->assertRedirectContains('login');
|
|
}
|
|
|
|
/**
|
|
* Test view method
|
|
*
|
|
* Tests the view action with a logged in user
|
|
*
|
|
* @return void
|
|
* @throws Exception
|
|
*
|
|
* @uses DeExternalAccountStatementsController::view
|
|
*/
|
|
public function testViewGetLoggedIn(): void
|
|
{
|
|
$id = '2f83162b-2bec-4826-8853-fbda2fac3a95';
|
|
$this->loginUserByRole('admin');
|
|
$url = [
|
|
'plugin' => 'CakeAccounting',
|
|
'controller' => 'DeExternalAccountStatements',
|
|
'action' => 'view',
|
|
$id,
|
|
];
|
|
$this->get($url);
|
|
$this->assertResponseCode(200);
|
|
}
|
|
}
|