first standalone plugin commit
This commit is contained in:
481
tests/TestCase/Controller/AddressesControllerTest.php
Normal file
481
tests/TestCase/Controller/AddressesControllerTest.php
Normal file
@@ -0,0 +1,481 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CakeAddresses\Test\TestCase\Controller;
|
||||
|
||||
use CakeAddresses\Controller\AddressesController;
|
||||
use CakeAddresses\Model\Table\AddressesTable;
|
||||
use PHPUnit\Exception;
|
||||
|
||||
/**
|
||||
* CakeAddresses\Controller\AddressesController Test Case
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\AddressesController
|
||||
*/
|
||||
class AddressesControllerTest extends BaseControllerTest
|
||||
{
|
||||
/**
|
||||
* Addresses Table
|
||||
*
|
||||
* @var \CakeAddresses\Model\Table\AddressesTable
|
||||
*/
|
||||
protected $Addresses;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeAddresses.Addresses',
|
||||
// 'plugin.CakeAddresses.Cities',
|
||||
'plugin.CakeAddresses.Countries',
|
||||
// 'plugin.CakeAddresses.Regions',
|
||||
'plugin.CakeAddresses.States',
|
||||
// 'plugin.CakeAddresses.Subregions',
|
||||
];
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->Addresses = $this->getTableLocator()->get('CakeAddresses.Addresses');
|
||||
$this->enableCsrfToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->Addresses);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test index method
|
||||
*
|
||||
* Tests the index action with an unauthenticated user (not logged in)
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\AddressesController::index()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGetUnauthenticated(): void
|
||||
{
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Addresses',
|
||||
'action' => 'index',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test index method
|
||||
*
|
||||
* Tests the index action with a logged in user
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\AddressesController::index()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGetLoggedIn(): void
|
||||
{
|
||||
$this->loginUserByRole();
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Addresses',
|
||||
'action' => 'index',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test view method
|
||||
*
|
||||
* Tests the view action with an unauthenticated user (not logged in)
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\AddressesController::view()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGetUnauthenticated(): void
|
||||
{
|
||||
$id = 1;
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Addresses',
|
||||
'action' => 'view',
|
||||
$id,
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test view method
|
||||
*
|
||||
* Tests the view action with a logged in user
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\AddressesController::view()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGetLoggedIn(): void
|
||||
{
|
||||
$id = 1;
|
||||
$this->loginUserByRole();
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Addresses',
|
||||
'action' => 'view',
|
||||
$id,
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test add method
|
||||
*
|
||||
* Tests the add action with an unauthenticated user (not logged in)
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\AddressesController::add()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddGetUnauthenticated(): void
|
||||
{
|
||||
$cntBefore = $this->Addresses->find()->count();
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Addresses',
|
||||
'action' => 'add',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('login');
|
||||
|
||||
$cntAfter = $this->Addresses->find()->count();
|
||||
$this->assertEquals($cntBefore, $cntAfter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test add method
|
||||
*
|
||||
* Tests the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\AddressesController::add()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddGetLoggedIn(): void
|
||||
{
|
||||
$cntBefore = $this->Addresses->find()->count();
|
||||
|
||||
$this->loginUserByRole();
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Addresses',
|
||||
'action' => 'add',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
|
||||
$cntAfter = $this->Addresses->find()->count();
|
||||
$this->assertEquals($cntBefore, $cntAfter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test add method
|
||||
*
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\AddressesController::add()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostLoggedInSuccess(): void
|
||||
{
|
||||
$cntBefore = $this->Addresses->find()->count();
|
||||
|
||||
$this->loginUserByRole();
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Addresses',
|
||||
'action' => 'add',
|
||||
];
|
||||
$data = [
|
||||
'address_name' => 'new address',
|
||||
'contact_name' => 'john doe',
|
||||
'address_line1' => '123 Test ST',
|
||||
'address_line2' => '',
|
||||
'city' => 'Seattle',
|
||||
'city_id' => '',
|
||||
'state_id' => 1462,
|
||||
'postal_code' => '98056',
|
||||
'country_id' => 233,
|
||||
'phone_number' => '',
|
||||
'email' => '',
|
||||
'notes' => '',
|
||||
];
|
||||
$this->post($url, $data);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('addresses');
|
||||
|
||||
$cntAfter = $this->Addresses->find()->count();
|
||||
$this->assertEquals($cntBefore + 1, $cntAfter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test add method
|
||||
*
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\AddressesController::add()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostLoggedInFailure(): void
|
||||
{
|
||||
$cntBefore = $this->Addresses->find()->count();
|
||||
|
||||
$this->loginUserByRole();
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Addresses',
|
||||
'action' => 'add',
|
||||
];
|
||||
$data = [
|
||||
'address_name' => '',
|
||||
'contact_name' => '',
|
||||
'address_line1' => '',
|
||||
'address_line2' => '',
|
||||
'city' => 'Seattle',
|
||||
'city_id' => '',
|
||||
'state_id' => 1462,
|
||||
'postal_code' => '98056',
|
||||
'country_id' => 233,
|
||||
'phone_number' => '',
|
||||
'email' => '',
|
||||
'notes' => '',
|
||||
];
|
||||
$this->post($url, $data);
|
||||
$this->assertResponseCode(200);
|
||||
|
||||
$cntAfter = $this->Addresses->find()->count();
|
||||
$this->assertEquals($cntBefore, $cntAfter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test edit method
|
||||
*
|
||||
* Tests the edit action with an unauthenticated user (not logged in)
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\AddressesController::edit()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditGetUnauthenticated(): void
|
||||
{
|
||||
$id = 1;
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Addresses',
|
||||
'action' => 'edit',
|
||||
$id,
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test edit method
|
||||
*
|
||||
* Tests the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\AddressesController::edit()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditGetLoggedIn(): void
|
||||
{
|
||||
$id = 1;
|
||||
$this->loginUserByRole();
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Addresses',
|
||||
'action' => 'edit',
|
||||
$id,
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test edit method
|
||||
*
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\AddressesController::edit()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutLoggedInSuccess(): void
|
||||
{
|
||||
$this->loginUserByRole();
|
||||
$id = 1;
|
||||
$before = $this->Addresses->get($id);
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Addresses',
|
||||
'action' => 'edit',
|
||||
$id,
|
||||
];
|
||||
$data = [
|
||||
// test new data here
|
||||
'address_name' => 'new address',
|
||||
'contact_name' => 'john doe',
|
||||
'address_line1' => '123 Test ST',
|
||||
'address_line2' => '',
|
||||
'city' => 'Seattle',
|
||||
'city_id' => '',
|
||||
'state_id' => 1462,
|
||||
'postal_code' => '98056',
|
||||
'country_id' => 233,
|
||||
'phone_number' => '',
|
||||
'email' => '',
|
||||
'notes' => '',
|
||||
];
|
||||
$this->put($url, $data);
|
||||
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('addresses');
|
||||
|
||||
$after = $this->Addresses->get($id);
|
||||
// assert saved properly below
|
||||
}
|
||||
|
||||
/**
|
||||
* Test edit method
|
||||
*
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\AddressesController::edit()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutLoggedInFailure(): void
|
||||
{
|
||||
$this->loginUserByRole();
|
||||
$id = 1;
|
||||
$before = $this->Addresses->get($id);
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Addresses',
|
||||
'action' => 'edit',
|
||||
$id,
|
||||
];
|
||||
$data = [
|
||||
'address_name' => '',
|
||||
'contact_name' => '',
|
||||
'address_line1' => '',
|
||||
'address_line2' => '',
|
||||
'city' => 'Seattle',
|
||||
'city_id' => '',
|
||||
'state_id' => 1462,
|
||||
'postal_code' => '98056',
|
||||
'country_id' => 233,
|
||||
'phone_number' => '',
|
||||
'email' => '',
|
||||
'notes' => '',
|
||||
];
|
||||
$this->put($url, $data);
|
||||
$this->assertResponseCode(200);
|
||||
$after = $this->Addresses->get($id);
|
||||
|
||||
// assert save failed below
|
||||
}
|
||||
|
||||
/**
|
||||
* Test delete method
|
||||
*
|
||||
* Tests the delete action with an unauthenticated user (not logged in)
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\AddressesController::delete()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDeleteUnauthenticated(): void
|
||||
{
|
||||
$cntBefore = $this->Addresses->find()->count();
|
||||
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Addresses',
|
||||
'action' => 'delete',
|
||||
1,
|
||||
];
|
||||
$this->delete($url);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('login');
|
||||
|
||||
$cntAfter = $this->Addresses->find()->count();
|
||||
$this->assertEquals($cntBefore, $cntAfter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test delete method
|
||||
*
|
||||
* Tests the delete action with a logged in user
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\AddressesController::delete()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDeleteLoggedIn(): void
|
||||
{
|
||||
$cntBefore = $this->Addresses->find()->count();
|
||||
|
||||
$this->loginUserByRole();
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Addresses',
|
||||
'action' => 'delete',
|
||||
1,
|
||||
];
|
||||
$this->delete($url);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('addresses');
|
||||
|
||||
$cntAfter = $this->Addresses->find()->count();
|
||||
$this->assertEquals($cntBefore - 1, $cntAfter);
|
||||
}
|
||||
}
|
||||
25
tests/TestCase/Controller/BaseControllerTest.php
Normal file
25
tests/TestCase/Controller/BaseControllerTest.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace CakeAddresses\Test\TestCase\Controller;
|
||||
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
|
||||
class BaseControllerTest extends TestCase
|
||||
{
|
||||
use IntegrationTestTrait;
|
||||
|
||||
public function loginUserByRole(string $role = 'admin'): void
|
||||
{
|
||||
$this->session(['Auth.User.id' => 1]);
|
||||
$this->session(['Auth.id' => 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testTest()
|
||||
{
|
||||
$this->assertEquals(1, 1);
|
||||
}
|
||||
}
|
||||
103
tests/TestCase/Controller/CitiesControllerTest.php
Normal file
103
tests/TestCase/Controller/CitiesControllerTest.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CakeAddresses\Test\TestCase\Controller;
|
||||
|
||||
use CakeAddresses\Controller\CitiesController;
|
||||
use PHPUnit\Exception;
|
||||
|
||||
/**
|
||||
* CakeAddresses\Controller\CitiesController Test Case
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\CitiesController
|
||||
*/
|
||||
class CitiesControllerTest extends BaseControllerTest
|
||||
{
|
||||
/**
|
||||
* Cities Table
|
||||
*
|
||||
* @var \CakeAddresses\Model\Table\CitiesTable
|
||||
*/
|
||||
protected $Cities;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
// 'plugin.CakeAddresses.Regions',
|
||||
// 'plugin.CakeAddresses.Subregions',
|
||||
'plugin.CakeAddresses.Countries',
|
||||
'plugin.CakeAddresses.States',
|
||||
'plugin.CakeAddresses.Cities',
|
||||
];
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->Cities = $this->getTableLocator()->get('Cities');
|
||||
$this->enableCsrfToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->Cities);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test select method
|
||||
*
|
||||
* Tests the select action with an unauthenticated user (not logged in)
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\CitiesController::select()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSelectGetUnauthenticated(): void
|
||||
{
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Cities',
|
||||
'action' => 'select',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test select method
|
||||
*
|
||||
* Tests the select action with a logged in user
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\CitiesController::select()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSelectGetLoggedIn(): void
|
||||
{
|
||||
$this->loginUserByRole();
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Cities',
|
||||
'action' => 'select',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
}
|
||||
}
|
||||
151
tests/TestCase/Controller/CountriesControllerTest.php
Normal file
151
tests/TestCase/Controller/CountriesControllerTest.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CakeAddresses\Test\TestCase\Controller;
|
||||
|
||||
use CakeAddresses\Controller\CountriesController;
|
||||
use PHPUnit\Exception;
|
||||
|
||||
/**
|
||||
* CakeAddresses\Controller\CountriesController Test Case
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\CountriesController
|
||||
*/
|
||||
class CountriesControllerTest extends BaseControllerTest
|
||||
{
|
||||
/**
|
||||
* AnsibleGroups Table
|
||||
*
|
||||
* @var \CakeAddresses\Model\Table\CountriesTable
|
||||
*/
|
||||
protected $Countries;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeAddresses.Regions',
|
||||
'plugin.CakeAddresses.Subregions',
|
||||
'plugin.CakeAddresses.Countries',
|
||||
'plugin.CakeAddresses.States',
|
||||
// 'plugin.CakeAddresses.Cities',
|
||||
];
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->Countries = $this->getTableLocator()->get('Countries');
|
||||
$this->enableCsrfToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->Countries);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test index method
|
||||
*
|
||||
* Tests the index action with an unauthenticated user (not logged in)
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\CountriesController::index()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGetUnauthenticated(): void
|
||||
{
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Countries',
|
||||
'action' => 'index',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test index method
|
||||
*
|
||||
* Tests the index action with a logged in user
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\CountriesController::index()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGetLoggedIn(): void
|
||||
{
|
||||
$this->loginUserByRole();
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Countries',
|
||||
'action' => 'index',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test view method
|
||||
*
|
||||
* Tests the view action with an unauthenticated user (not logged in)
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\CountriesController::view()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGetUnauthenticated(): void
|
||||
{
|
||||
$id = 233;
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Countries',
|
||||
'action' => 'view',
|
||||
$id,
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test view method
|
||||
*
|
||||
* Tests the view action with a logged in user
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\CountriesController::view()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGetLoggedIn(): void
|
||||
{
|
||||
$id = 233;
|
||||
$this->loginUserByRole();
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Countries',
|
||||
'action' => 'view',
|
||||
$id,
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
}
|
||||
}
|
||||
154
tests/TestCase/Controller/RegionsControllerTest.php
Normal file
154
tests/TestCase/Controller/RegionsControllerTest.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CakeAddresses\Test\TestCase\Controller;
|
||||
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeAddresses\Controller\RegionsController;
|
||||
use PHPUnit\Exception;
|
||||
|
||||
/**
|
||||
* CakeAddresses\Controller\RegionsController Test Case
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\RegionsController
|
||||
*/
|
||||
class RegionsControllerTest extends BaseControllerTest
|
||||
{
|
||||
/**
|
||||
* Regions Table
|
||||
*
|
||||
* @var \CakeAddresses\Model\Table\RegionsTable
|
||||
*/
|
||||
protected $Regions;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeAddresses.Regions',
|
||||
// 'plugin.CakeAddresses.Subregions',
|
||||
// 'plugin.CakeAddresses.Countries',
|
||||
// 'plugin.CakeAddresses.States',
|
||||
// 'plugin.CakeAddresses.Cities',
|
||||
];
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->Regions = $this->getTableLocator()->get('Regions');
|
||||
$this->enableCsrfToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->Regions);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test index method
|
||||
*
|
||||
* Tests the index action with an unauthenticated user (not logged in)
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\RegionsController::index()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGetUnauthenticated(): void
|
||||
{
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Regions',
|
||||
'action' => 'index',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test index method
|
||||
*
|
||||
* Tests the index action with a logged in user
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\RegionsController::index()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGetLoggedIn(): void
|
||||
{
|
||||
$this->loginUserByRole();
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Regions',
|
||||
'action' => 'index',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test view method
|
||||
*
|
||||
* Tests the view action with an unauthenticated user (not logged in)
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\RegionsController::view()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGetUnauthenticated(): void
|
||||
{
|
||||
$id = 1;
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Regions',
|
||||
'action' => 'view',
|
||||
$id,
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test view method
|
||||
*
|
||||
* Tests the view action with a logged in user
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\RegionsController::view()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGetLoggedIn(): void
|
||||
{
|
||||
$id = 1;
|
||||
|
||||
$this->loginUserByRole();
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Regions',
|
||||
'action' => 'view',
|
||||
$id,
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
}
|
||||
}
|
||||
150
tests/TestCase/Controller/StatesControllerTest.php
Normal file
150
tests/TestCase/Controller/StatesControllerTest.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CakeAddresses\Test\TestCase\Controller;
|
||||
|
||||
use CakeAddresses\Controller\StatesController;
|
||||
use PHPUnit\Exception;
|
||||
|
||||
/**
|
||||
* CakeAddresses\Controller\StatesController Test Case
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\StatesController
|
||||
*/
|
||||
class StatesControllerTest extends BaseControllerTest
|
||||
{
|
||||
/**
|
||||
* States Table
|
||||
*
|
||||
* @var \CakeAddresses\Model\Table\StatesTable
|
||||
*/
|
||||
protected $States;
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
// 'plugin.CakeAddresses.Regions',
|
||||
// 'plugin.CakeAddresses.Subregions',
|
||||
'plugin.CakeAddresses.Countries',
|
||||
'plugin.CakeAddresses.States',
|
||||
// 'plugin.CakeAddresses.Cities',
|
||||
];
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->States = $this->getTableLocator()->get('States');
|
||||
$this->enableCsrfToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->States);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test index method
|
||||
*
|
||||
* Tests the index action with an unauthenticated user (not logged in)
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\StatesController::index()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGetUnauthenticated(): void
|
||||
{
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'States',
|
||||
'action' => 'index',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test index method
|
||||
*
|
||||
* Tests the index action with a logged in user
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\StatesController::index()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGetLoggedIn(): void
|
||||
{
|
||||
$this->loginUserByRole();
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'States',
|
||||
'action' => 'index',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test view method
|
||||
*
|
||||
* Tests the view action with an unauthenticated user (not logged in)
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\StatesController::view()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGetUnauthenticated(): void
|
||||
{
|
||||
$id = 1462;
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'States',
|
||||
'action' => 'view',
|
||||
$id,
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test view method
|
||||
*
|
||||
* Tests the view action with a logged in user
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\StatesController::view()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGetLoggedIn(): void
|
||||
{
|
||||
$id = 1462;
|
||||
$this->loginUserByRole();
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'States',
|
||||
'action' => 'view',
|
||||
$id,
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
}
|
||||
}
|
||||
154
tests/TestCase/Controller/SubregionsControllerTest.php
Normal file
154
tests/TestCase/Controller/SubregionsControllerTest.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CakeAddresses\Test\TestCase\Controller;
|
||||
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeAddresses\Controller\SubregionsController;
|
||||
use PHPUnit\Exception;
|
||||
|
||||
/**
|
||||
* CakeAddresses\Controller\SubregionsController Test Case
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\SubregionsController
|
||||
*/
|
||||
class SubregionsControllerTest extends BaseControllerTest
|
||||
{
|
||||
/**
|
||||
* Subregions Table
|
||||
*
|
||||
* @var \CakeAddresses\Model\Table\SubregionsTable
|
||||
*/
|
||||
protected $Subregions;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeAddresses.Regions',
|
||||
'plugin.CakeAddresses.Subregions',
|
||||
'plugin.CakeAddresses.Countries',
|
||||
// 'plugin.CakeAddresses.States',
|
||||
// 'plugin.CakeAddresses.Cities',
|
||||
];
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->Subregions = $this->getTableLocator()->get('Subregions');
|
||||
$this->enableCsrfToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->Subregions);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test index method
|
||||
*
|
||||
* Tests the index action with an unauthenticated user (not logged in)
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\SubregionsController::index()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGetUnauthenticated(): void
|
||||
{
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Subregions',
|
||||
'action' => 'index',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test index method
|
||||
*
|
||||
* Tests the index action with a logged in user
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\SubregionsController::index()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGetLoggedIn(): void
|
||||
{
|
||||
$this->loginUserByRole();
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Subregions',
|
||||
'action' => 'index',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test view method
|
||||
*
|
||||
* Tests the view action with an unauthenticated user (not logged in)
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\SubregionsController::view()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGetUnauthenticated(): void
|
||||
{
|
||||
$id = 1;
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Subregions',
|
||||
'action' => 'view',
|
||||
$id,
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test view method
|
||||
*
|
||||
* Tests the view action with a logged in user
|
||||
*
|
||||
* @uses \CakeAddresses\Controller\SubregionsController::view()
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGetLoggedIn(): void
|
||||
{
|
||||
$id = 1;
|
||||
|
||||
$this->loginUserByRole();
|
||||
$url = [
|
||||
'plugin' => 'CakeAddresses',
|
||||
'controller' => 'Subregions',
|
||||
'action' => 'view',
|
||||
$id,
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
}
|
||||
}
|
||||
111
tests/TestCase/Model/Table/AddressesTableTest.php
Normal file
111
tests/TestCase/Model/Table/AddressesTableTest.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CakeAddresses\Test\TestCase\Model\Table;
|
||||
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeAddresses\Model\Table\AddressesTable;
|
||||
|
||||
/**
|
||||
* CakeAddresses\Model\Table\AddressesTable Test Case
|
||||
*/
|
||||
class AddressesTableTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var \CakeAddresses\Model\Table\AddressesTable
|
||||
*/
|
||||
protected $Addresses;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeAddresses.Addresses',
|
||||
'plugin.CakeAddresses.Cities',
|
||||
'plugin.CakeAddresses.States',
|
||||
'plugin.CakeAddresses.Countries',
|
||||
];
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('Addresses') ? [] : ['className' => AddressesTable::class];
|
||||
$this->Addresses = $this->getTableLocator()->get('Addresses', $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* TestInitialize method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeAddresses\Model\Table\AddressesTable::initialize()
|
||||
*/
|
||||
public function testInitialize(): void
|
||||
{
|
||||
// verify all associations loaded
|
||||
$expectedAssociations = [
|
||||
'Cities',
|
||||
'States',
|
||||
'Countries',
|
||||
];
|
||||
$associations = $this->Addresses->associations();
|
||||
|
||||
$this->assertCount(count($expectedAssociations), $associations);
|
||||
foreach ($expectedAssociations as $expectedAssociation) {
|
||||
$this->assertTrue($this->Addresses->hasAssociation($expectedAssociation), 'Failed asserting Addresses has the association: ' . $expectedAssociation);
|
||||
}
|
||||
|
||||
// verify all behaviors loaded
|
||||
$expectedBehaviors = [
|
||||
];
|
||||
$behaviors = $this->Addresses->behaviors();
|
||||
|
||||
$this->assertCount(count($expectedBehaviors), $behaviors);
|
||||
foreach ($expectedBehaviors as $expectedBehavior) {
|
||||
$this->assertTrue($this->Addresses->hasBehavior($expectedBehavior));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->Addresses);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test validationDefault method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeAddresses\Model\Table\AddressesTable::validationDefault()
|
||||
*/
|
||||
public function testValidationDefault(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test buildRules method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeAddresses\Model\Table\AddressesTable::buildRules()
|
||||
*/
|
||||
public function testBuildRules(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
}
|
||||
111
tests/TestCase/Model/Table/CitiesTableTest.php
Normal file
111
tests/TestCase/Model/Table/CitiesTableTest.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CakeAddresses\Test\TestCase\Model\Table;
|
||||
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeAddresses\Model\Table\CitiesTable;
|
||||
|
||||
/**
|
||||
* CakeAddresses\Model\Table\CitiesTable Test Case
|
||||
*/
|
||||
class CitiesTableTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var \CakeAddresses\Model\Table\CitiesTable
|
||||
*/
|
||||
protected $Cities;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeAddresses.Cities',
|
||||
'plugin.CakeAddresses.States',
|
||||
'plugin.CakeAddresses.Countries',
|
||||
'plugin.CakeAddresses.Addresses',
|
||||
];
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('Cities') ? [] : ['className' => CitiesTable::class];
|
||||
$this->Cities = $this->getTableLocator()->get('Cities', $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->Cities);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* TestInitialize method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeAddresses\Model\Table\CitiesTable::initialize()
|
||||
*/
|
||||
public function testInitialize(): void
|
||||
{
|
||||
// verify all associations loaded
|
||||
$expectedAssociations = [
|
||||
'States',
|
||||
'Countries',
|
||||
'Addresses',
|
||||
];
|
||||
$associations = $this->Cities->associations();
|
||||
|
||||
$this->assertCount(count($expectedAssociations), $associations);
|
||||
foreach ($expectedAssociations as $expectedAssociation) {
|
||||
$this->assertTrue($this->Cities->hasAssociation($expectedAssociation), 'Failed asserting Cities has the association: ' . $expectedAssociation);
|
||||
}
|
||||
|
||||
// verify all behaviors loaded
|
||||
$expectedBehaviors = [
|
||||
];
|
||||
$behaviors = $this->Cities->behaviors();
|
||||
|
||||
$this->assertCount(count($expectedBehaviors), $behaviors);
|
||||
foreach ($expectedBehaviors as $expectedBehavior) {
|
||||
$this->assertTrue($this->Cities->hasBehavior($expectedBehavior));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test validationDefault method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeAddresses\Model\Table\CitiesTable::validationDefault()
|
||||
*/
|
||||
public function testValidationDefault(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test buildRules method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeAddresses\Model\Table\CitiesTable::buildRules()
|
||||
*/
|
||||
public function testBuildRules(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
}
|
||||
80
tests/TestCase/Model/Table/CountriesTableTest.php
Normal file
80
tests/TestCase/Model/Table/CountriesTableTest.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CakeAddresses\Test\TestCase\Model\Table;
|
||||
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeAddresses\Model\Table\CountriesTable;
|
||||
|
||||
/**
|
||||
* CakeAddresses\Model\Table\CountriesTable Test Case
|
||||
*/
|
||||
class CountriesTableTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var \CakeAddresses\Model\Table\CountriesTable
|
||||
*/
|
||||
protected $Countries;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeAddresses.Countries',
|
||||
'plugin.CakeAddresses.Regions',
|
||||
'plugin.CakeAddresses.Subregions',
|
||||
'plugin.CakeAddresses.Addresses',
|
||||
'plugin.CakeAddresses.Cities',
|
||||
'plugin.CakeAddresses.States',
|
||||
];
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('Countries') ? [] : ['className' => CountriesTable::class];
|
||||
$this->Countries = $this->getTableLocator()->get('Countries', $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->Countries);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test validationDefault method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeAddresses\Model\Table\CountriesTable::validationDefault()
|
||||
*/
|
||||
public function testValidationDefault(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test buildRules method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeAddresses\Model\Table\CountriesTable::buildRules()
|
||||
*/
|
||||
public function testBuildRules(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
}
|
||||
97
tests/TestCase/Model/Table/RegionsTableTest.php
Normal file
97
tests/TestCase/Model/Table/RegionsTableTest.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CakeAddresses\Test\TestCase\Model\Table;
|
||||
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeAddresses\Model\Table\RegionsTable;
|
||||
|
||||
/**
|
||||
* CakeAddresses\Model\Table\RegionsTable Test Case
|
||||
*/
|
||||
class RegionsTableTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var \CakeAddresses\Model\Table\RegionsTable
|
||||
*/
|
||||
protected $Regions;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeAddresses.Regions',
|
||||
'plugin.CakeAddresses.Countries',
|
||||
'plugin.CakeAddresses.Subregions',
|
||||
];
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('Regions') ? [] : ['className' => RegionsTable::class];
|
||||
$this->Regions = $this->getTableLocator()->get('Regions', $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->Regions);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* TestInitialize method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeAddresses\Model\Table\RegionsTable::initialize()
|
||||
*/
|
||||
public function testInitialize(): void
|
||||
{
|
||||
// verify all associations loaded
|
||||
$expectedAssociations = [
|
||||
'Countries',
|
||||
'Subregions',
|
||||
// 'States',
|
||||
];
|
||||
$associations = $this->Regions->associations();
|
||||
|
||||
$this->assertCount(count($expectedAssociations), $associations);
|
||||
foreach ($expectedAssociations as $expectedAssociation) {
|
||||
$this->assertTrue($this->Regions->hasAssociation($expectedAssociation));
|
||||
}
|
||||
|
||||
// verify all behaviors loaded
|
||||
$expectedBehaviors = [];
|
||||
$behaviors = $this->Regions->behaviors();
|
||||
|
||||
$this->assertCount(count($expectedBehaviors), $behaviors);
|
||||
foreach ($expectedBehaviors as $expectedBehavior) {
|
||||
$this->assertTrue($this->Regions->hasBehavior($expectedBehavior));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test validationDefault method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeAddresses\Model\Table\RegionsTable::validationDefault()
|
||||
*/
|
||||
public function testValidationDefault(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
}
|
||||
78
tests/TestCase/Model/Table/StatesTableTest.php
Normal file
78
tests/TestCase/Model/Table/StatesTableTest.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CakeAddresses\Test\TestCase\Model\Table;
|
||||
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeAddresses\Model\Table\StatesTable;
|
||||
|
||||
/**
|
||||
* CakeAddresses\Model\Table\StatesTable Test Case
|
||||
*/
|
||||
class StatesTableTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var \CakeAddresses\Model\Table\StatesTable
|
||||
*/
|
||||
protected $States;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeAddresses.States',
|
||||
'plugin.CakeAddresses.Countries',
|
||||
'plugin.CakeAddresses.Addresses',
|
||||
'plugin.CakeAddresses.Cities',
|
||||
];
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('States') ? [] : ['className' => StatesTable::class];
|
||||
$this->States = $this->getTableLocator()->get('States', $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->States);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test validationDefault method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeAddresses\Model\Table\StatesTable::validationDefault()
|
||||
*/
|
||||
public function testValidationDefault(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test buildRules method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeAddresses\Model\Table\StatesTable::buildRules()
|
||||
*/
|
||||
public function testBuildRules(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
}
|
||||
77
tests/TestCase/Model/Table/SubregionsTableTest.php
Normal file
77
tests/TestCase/Model/Table/SubregionsTableTest.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CakeAddresses\Test\TestCase\Model\Table;
|
||||
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeAddresses\Model\Table\SubregionsTable;
|
||||
|
||||
/**
|
||||
* CakeAddresses\Model\Table\SubregionsTable Test Case
|
||||
*/
|
||||
class SubregionsTableTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var \CakeAddresses\Model\Table\SubregionsTable
|
||||
*/
|
||||
protected $Subregions;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeAddresses.Subregions',
|
||||
'plugin.CakeAddresses.Regions',
|
||||
'plugin.CakeAddresses.Countries',
|
||||
];
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('Subregions') ? [] : ['className' => SubregionsTable::class];
|
||||
$this->Subregions = $this->getTableLocator()->get('Subregions', $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->Subregions);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test validationDefault method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeAddresses\Model\Table\SubregionsTable::validationDefault()
|
||||
*/
|
||||
public function testValidationDefault(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test buildRules method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeAddresses\Model\Table\SubregionsTable::buildRules()
|
||||
*/
|
||||
public function testBuildRules(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user