from main app code base

This commit is contained in:
2025-03-27 01:11:41 -07:00
parent b17634c08a
commit d9a59fb82b
18 changed files with 131 additions and 1034 deletions

View File

@@ -9,13 +9,6 @@ class BaseControllerTest extends TestCase
{
use IntegrationTestTrait;
protected function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub
$this->loadPlugins(['CakeProducts']);
}
public function loginUserByRole(string $role = 'admin'): void
{
$this->session(['Auth.User.id' => 1]);

View File

@@ -3,6 +3,7 @@ declare(strict_types=1);
namespace CakeProducts\Test\TestCase\Controller;
use Cake\Log\Log;
use Cake\ORM\Table;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
@@ -59,28 +60,6 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
parent::tearDown();
}
/**
* Test index method
*
* Tests the index action with an unauthenticated user (not logged in)
*
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::index()
* @throws Exception
*
* @return void
*/
public function testIndexGetUnauthenticated(): void
{
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test index method
*
@@ -91,8 +70,9 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
*
* @return void
*/
public function testIndexGetLoggedIn(): void
public function testIndexGet(): void
{
Log::debug('inside testIndexGet ExternalProductCatalogsControllerTest');
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
@@ -103,30 +83,6 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
$this->assertResponseCode(200);
}
/**
* Test view method
*
* Tests the view action with an unauthenticated user (not logged in)
*
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::view()
* @throws Exception
*
* @return void
*/
public function testViewGetUnauthenticated(): void
{
$id = 1;
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test view method
*
@@ -137,7 +93,7 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
*
* @return void
*/
public function testViewGetLoggedIn(): void
public function testViewGet(): void
{
$id = 1;
$this->loginUserByRole('admin');
@@ -151,32 +107,6 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
$this->assertResponseCode(200);
}
/**
* Test add method
*
* Tests the add action with an unauthenticated user (not logged in)
*
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::add()
* @throws Exception
*
* @return void
*/
public function testAddGetUnauthenticated(): void
{
$cntBefore = $this->ExternalProductCatalogs->find()->count();
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
$cntAfter = $this->ExternalProductCatalogs->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test add method
*
@@ -187,7 +117,7 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
*
* @return void
*/
public function testAddGetLoggedIn(): void
public function testAddGet(): void
{
$cntBefore = $this->ExternalProductCatalogs->find()->count();
@@ -214,7 +144,7 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
*
* @return void
*/
public function testAddPostLoggedInSuccess(): void
public function testAddPostSuccess(): void
{
$cntBefore = $this->ExternalProductCatalogs->find()->count();
@@ -248,7 +178,7 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
*
* @return void
*/
public function testAddPostLoggedInFailure(): void
public function testAddPostFailure(): void
{
$cntBefore = $this->ExternalProductCatalogs->find()->count();
@@ -271,29 +201,6 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test edit method
*
* Tests the edit action with an unauthenticated user (not logged in)
*
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::edit()
* @throws Exception
*
* @return void
*/
public function testEditGetUnauthenticated(): void
{
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'edit',
1,
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test edit method
*
@@ -304,7 +211,7 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
*
* @return void
*/
public function testEditGetLoggedIn(): void
public function testEditGet(): void
{
$this->loginUserByRole('admin');
$url = [
@@ -327,7 +234,7 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
*
* @return void
*/
public function testEditPutLoggedInSuccess(): void
public function testEditPutSuccess(): void
{
$this->loginUserByRole('admin');
$id = 1;
@@ -363,7 +270,7 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
*
* @return void
*/
public function testEditPutLoggedInFailure(): void
public function testEditPutFailure(): void
{
$this->loginUserByRole('admin');
$id = 1;
@@ -387,34 +294,6 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
// assert save failed below
}
/**
* Test delete method
*
* Tests the delete action with an unauthenticated user (not logged in)
*
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::delete()
* @throws Exception
*
* @return void
*/
public function testDeleteUnauthenticated(): void
{
$cntBefore = $this->ExternalProductCatalogs->find()->count();
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'delete',
1,
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
$cntAfter = $this->ExternalProductCatalogs->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test delete method
*
@@ -425,7 +304,7 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
*
* @return void
*/
public function testDeleteLoggedIn(): void
public function testDelete(): void
{
$cntBefore = $this->ExternalProductCatalogs->find()->count();

View File

@@ -60,28 +60,6 @@ class ProductCatalogsControllerTest extends BaseControllerTest
parent::tearDown();
}
/**
* Test index method
*
* Tests the index action with an unauthenticated user (not logged in)
*
* @uses ProductCatalogsController::index()
* @throws Exception
*
* @return void
*/
public function testIndexGetUnauthenticated(): void
{
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test index method
*
@@ -92,7 +70,7 @@ class ProductCatalogsControllerTest extends BaseControllerTest
*
* @return void
*/
public function testIndexGetLoggedIn(): void
public function testIndexGet(): void
{
$this->loginUserByRole('admin');
$url = [
@@ -104,30 +82,6 @@ class ProductCatalogsControllerTest extends BaseControllerTest
$this->assertResponseCode(200);
}
/**
* Test view method
*
* Tests the view action with an unauthenticated user (not logged in)
*
* @uses ProductCatalogsController::view()
* @throws Exception
*
* @return void
*/
public function testViewGetUnauthenticated(): void
{
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test view method
*
@@ -138,7 +92,7 @@ class ProductCatalogsControllerTest extends BaseControllerTest
*
* @return void
*/
public function testViewGetLoggedIn(): void
public function testViewGet(): void
{
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
$this->loginUserByRole('admin');
@@ -152,32 +106,6 @@ class ProductCatalogsControllerTest extends BaseControllerTest
$this->assertResponseCode(200);
}
/**
* Test add method
*
* Tests the add action with an unauthenticated user (not logged in)
*
* @uses ProductCatalogsController::add()
* @throws Exception
*
* @return void
*/
public function testAddGetUnauthenticated(): void
{
$cntBefore = $this->ProductCatalogs->find()->count();
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
$cntAfter = $this->ProductCatalogs->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test add method
*
@@ -188,7 +116,7 @@ class ProductCatalogsControllerTest extends BaseControllerTest
*
* @return void
*/
public function testAddGetLoggedIn(): void
public function testAddGet(): void
{
$cntBefore = $this->ProductCatalogs->find()->count();
@@ -215,7 +143,7 @@ class ProductCatalogsControllerTest extends BaseControllerTest
*
* @return void
*/
public function testAddPostLoggedInSuccess(): void
public function testAddPostSuccess(): void
{
$cntBefore = $this->ProductCatalogs->find()->count();
@@ -248,7 +176,7 @@ class ProductCatalogsControllerTest extends BaseControllerTest
*
* @return void
*/
public function testAddPostLoggedInFailure(): void
public function testAddPostFailure(): void
{
$cntBefore = $this->ProductCatalogs->find()->count();
@@ -270,30 +198,6 @@ class ProductCatalogsControllerTest extends BaseControllerTest
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test edit method
*
* Tests the edit action with an unauthenticated user (not logged in)
*
* @uses ProductCatalogsController::edit()
* @throws Exception
*
* @return void
*/
public function testEditGetUnauthenticated(): void
{
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'edit',
$id,
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test edit method
*
@@ -304,7 +208,7 @@ class ProductCatalogsControllerTest extends BaseControllerTest
*
* @return void
*/
public function testEditGetLoggedIn(): void
public function testEditGet(): void
{
$this->loginUserByRole('admin');
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
@@ -328,7 +232,7 @@ class ProductCatalogsControllerTest extends BaseControllerTest
*
* @return void
*/
public function testEditPutLoggedInSuccess(): void
public function testEditPutSuccess(): void
{
$this->loginUserByRole('admin');
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
@@ -366,7 +270,7 @@ class ProductCatalogsControllerTest extends BaseControllerTest
*
* @return void
*/
public function testEditPutLoggedInFailure(): void
public function testEditPutFailure(): void
{
$this->loginUserByRole('admin');
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
@@ -390,34 +294,6 @@ class ProductCatalogsControllerTest extends BaseControllerTest
// assert save failed below
}
/**
* Test delete method
*
* Tests the delete action with an unauthenticated user (not logged in)
*
* @uses ProductCatalogsController::delete()
* @throws Exception
*
* @return void
*/
public function testDeleteUnauthenticated(): void
{
$cntBefore = $this->ProductCatalogs->find()->count();
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'delete',
1,
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
$cntAfter = $this->ProductCatalogs->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test delete method
*
@@ -428,7 +304,7 @@ class ProductCatalogsControllerTest extends BaseControllerTest
*
* @return void
*/
public function testDeleteLoggedIn(): void
public function testDelete(): void
{
$cntBefore = $this->ProductCatalogs->find()->count();

View File

@@ -59,28 +59,6 @@ class ProductCategoriesControllerTest extends BaseControllerTest
parent::tearDown();
}
/**
* Test index method
*
* Tests the index action with an unauthenticated user (not logged in)
*
* @return void
* @throws Exception
*
* @uses ProductCategoriesController::index
*/
public function testIndexGetUnauthenticated(): void
{
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test index method
*
@@ -91,7 +69,7 @@ class ProductCategoriesControllerTest extends BaseControllerTest
*
* @uses ProductCategoriesController::index
*/
public function testIndexGetLoggedIn(): void
public function testIndexGet(): void
{
$this->loginUserByRole('admin');
$url = [
@@ -103,30 +81,6 @@ class ProductCategoriesControllerTest extends BaseControllerTest
$this->assertResponseCode(200);
}
/**
* Test view method
*
* Tests the view action with an unauthenticated user (not logged in)
*
* @return void
* @throws Exception
*
* @uses ProductCategoriesController::view
*/
public function testViewGetUnauthenticated(): void
{
$id = 1;
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test view method
*
@@ -137,7 +91,7 @@ class ProductCategoriesControllerTest extends BaseControllerTest
*
* @uses ProductCategoriesController::view
*/
public function testViewGetLoggedIn(): void
public function testViewGet(): void
{
$id = 1;
$this->loginUserByRole('admin');
@@ -151,32 +105,6 @@ class ProductCategoriesControllerTest extends BaseControllerTest
$this->assertResponseCode(200);
}
/**
* Test add method
*
* Tests the add action with an unauthenticated user (not logged in)
*
* @return void
* @throws Exception
*
* @uses ProductCategoriesController::add
*/
public function testAddGetUnauthenticated(): void
{
$cntBefore = $this->ProductCategories->find()->count();
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
$cntAfter = $this->ProductCategories->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test add method
*
@@ -187,7 +115,7 @@ class ProductCategoriesControllerTest extends BaseControllerTest
*
* @uses ProductCategoriesController::add
*/
public function testAddGetLoggedIn(): void
public function testAddGet(): void
{
$cntBefore = $this->ProductCategories->find()->count();
@@ -214,7 +142,7 @@ class ProductCategoriesControllerTest extends BaseControllerTest
*
* @uses ProductCategoriesController::add
*/
public function testAddPostLoggedInSuccess(): void
public function testAddPostSuccess(): void
{
$cntBefore = $this->ProductCategories->find()->count();
@@ -249,7 +177,7 @@ class ProductCategoriesControllerTest extends BaseControllerTest
*
* @uses ProductCategoriesController::add
*/
public function testAddPostLoggedInFailure(): void
public function testAddPostFailure(): void
{
$cntBefore = $this->ProductCategories->find()->count();
@@ -273,29 +201,6 @@ class ProductCategoriesControllerTest extends BaseControllerTest
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test edit method
*
* Tests the edit action with an unauthenticated user (not logged in)
*
* @return void
* @throws Exception
*
* @uses ProductCategoriesController::edit
*/
public function testEditGetUnauthenticated(): void
{
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'edit',
1,
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test edit method
*
@@ -306,7 +211,7 @@ class ProductCategoriesControllerTest extends BaseControllerTest
*
* @uses ProductCategoriesController::edit
*/
public function testEditGetLoggedIn(): void
public function testEditGet(): void
{
$this->loginUserByRole('admin');
$url = [
@@ -329,7 +234,7 @@ class ProductCategoriesControllerTest extends BaseControllerTest
*
* @uses ProductCategoriesController::edit
*/
public function testEditPutLoggedInSuccess(): void
public function testEditPutSuccess(): void
{
$this->loginUserByRole('admin');
$id = 1;
@@ -371,7 +276,7 @@ class ProductCategoriesControllerTest extends BaseControllerTest
*
* @uses ProductCategoriesController::edit
*/
public function testEditPutLoggedInFailure(): void
public function testEditPutFailure(): void
{
$this->loginUserByRole('admin');
$id = 1;
@@ -396,34 +301,6 @@ class ProductCategoriesControllerTest extends BaseControllerTest
// assert save failed below
}
/**
* Test delete method
*
* Tests the delete action with an unauthenticated user (not logged in)
*
* @return void
* @throws Exception
*
* @uses ProductCategoriesController::delete
*/
public function testDeleteUnauthenticated(): void
{
$cntBefore = $this->ProductCategories->find()->count();
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'delete',
1,
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
$cntAfter = $this->ProductCategories->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test delete method
*
@@ -434,7 +311,7 @@ class ProductCategoriesControllerTest extends BaseControllerTest
*
* @uses ProductCategoriesController::delete
*/
public function testDeleteLoggedIn(): void
public function testDelete(): void
{
$cntBefore = $this->ProductCategories->find()->count();

View File

@@ -58,32 +58,6 @@ class ProductCategoryAttributeOptionsControllerTest extends BaseControllerTest
parent::tearDown();
}
/**
* Test add method
*
* Tests the add action with an unauthenticated user (not logged in)
*
* @return void
* @throws Exception
*
* @uses CustomersContactsController::add
*/
public function testAddGetUnauthenticated(): void
{
$cntBefore = $this->ProductCategoryAttributeOptions->find()->count();
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributeOptions',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
$cntAfter = $this->ProductCategoryAttributeOptions->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test add method
*
@@ -94,7 +68,7 @@ class ProductCategoryAttributeOptionsControllerTest extends BaseControllerTest
*
* @uses CustomersContactsController::add
*/
public function testAddGetLoggedIn(): void
public function testAddGet(): void
{
$cntBefore = $this->ProductCategoryAttributeOptions->find()->count();
@@ -121,7 +95,7 @@ class ProductCategoryAttributeOptionsControllerTest extends BaseControllerTest
*
* @uses CustomersContactsController::add
*/
public function testAddPostLoggedInHasNoEffect(): void
public function testAddPostHasNoEffect(): void
{
$cntBefore = $this->ProductCategoryAttributeOptions->find()->count();
@@ -139,34 +113,6 @@ class ProductCategoryAttributeOptionsControllerTest extends BaseControllerTest
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test delete method
*
* Tests the delete action with an unauthenticated user (not logged in)
*
* @return void
* @throws Exception
*
* @uses CustomersContactsController::delete
*/
public function testDeleteUnauthenticated(): void
{
$cntBefore = $this->ProductCategoryAttributeOptions->find()->count();
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributeOptions',
'action' => 'delete',
'e06f1723-2456-483a-b3c4-004603e032a8',
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
$cntAfter = $this->ProductCategoryAttributeOptions->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test delete method
*
@@ -177,7 +123,7 @@ class ProductCategoryAttributeOptionsControllerTest extends BaseControllerTest
*
* @uses CustomersContactsController::delete
*/
public function testDeleteLoggedIn(): void
public function testDelete(): void
{
$cntBefore = $this->ProductCategoryAttributeOptions->find()->count();

View File

@@ -60,28 +60,6 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
parent::tearDown();
}
/**
* Test index method
*
* Tests the index action with an unauthenticated user (not logged in)
*
* @return void
* @throws Exception
*
* @uses ProductCategoryAttributesController::index
*/
public function testIndexGetUnauthenticated(): void
{
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test index method
*
@@ -92,7 +70,7 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
*
* @uses ProductCategoryAttributesController::index
*/
public function testIndexGetLoggedIn(): void
public function testIndexGet(): void
{
$this->loginUserByRole('admin');
$url = [
@@ -104,30 +82,6 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
$this->assertResponseCode(200);
}
/**
* Test view method
*
* Tests the view action with an unauthenticated user (not logged in)
*
* @return void
* @throws Exception
*
* @uses ProductCategoryAttributesController::view
*/
public function testViewGetUnauthenticated(): void
{
$id = '37078cf0-0130-4b93-bb7e-abe7d665ed2c';
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test view method
*
@@ -138,7 +92,7 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
*
* @uses ProductCategoryAttributesController::view
*/
public function testViewGetLoggedIn(): void
public function testViewGet(): void
{
$id = '37078cf0-0130-4b93-bb7e-abe7d665ed2c';
$this->loginUserByRole('admin');
@@ -152,32 +106,6 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
$this->assertResponseCode(200);
}
/**
* Test add method
*
* Tests the add action with an unauthenticated user (not logged in)
*
* @return void
* @throws Exception
*
* @uses ProductCategoryAttributesController::add
*/
public function testAddGetUnauthenticated(): void
{
$cntBefore = $this->ProductCategoryAttributes->find()->count();
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
$cntAfter = $this->ProductCategoryAttributes->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test add method
*
@@ -188,7 +116,7 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
*
* @uses ProductCategoryAttributesController::add
*/
public function testAddGetLoggedIn(): void
public function testAddGet(): void
{
$cntBefore = $this->ProductCategoryAttributes->find()->count();
@@ -215,7 +143,7 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
*
* @uses ProductCategoryAttributesController::add
*/
public function testAddPostLoggedInSuccess(): void
public function testAddPostSuccess(): void
{
$cntBefore = $this->ProductCategoryAttributes->find()->count();
@@ -249,7 +177,7 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
*
* @uses ProductCategoryAttributesController::add
*/
public function testAddPostLoggedInSuccessConstrainedWithOptions(): void
public function testAddPostSuccessConstrainedWithOptions(): void
{
$cntBefore = $this->ProductCategoryAttributes->find()->count();
$cntOptionsBefore = $this->ProductCategoryAttributes->ProductCategoryAttributeOptions->find()->count();
@@ -299,7 +227,7 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
*
* @uses ProductCategoryAttributesController::add
*/
public function testAddPostLoggedInFailure(): void
public function testAddPostFailure(): void
{
$cntBefore = $this->ProductCategoryAttributes->find()->count();
@@ -322,29 +250,6 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test edit method
*
* Tests the edit action with an unauthenticated user (not logged in)
*
* @return void
* @throws Exception
*
* @uses ProductCategoryAttributesController::edit
*/
public function testEditGetUnauthenticated(): void
{
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'edit',
'37078cf0-0130-4b93-bb7e-abe7d665ed2c',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test edit method
*
@@ -355,7 +260,7 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
*
* @uses ProductCategoryAttributesController::edit
*/
public function testEditGetLoggedIn(): void
public function testEditGet(): void
{
$this->loginUserByRole('admin');
$url = [
@@ -378,7 +283,7 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
*
* @uses ProductCategoryAttributesController::edit
*/
public function testEditPutLoggedInSuccess(): void
public function testEditPutSuccess(): void
{
$this->loginUserByRole('admin');
$id = '37078cf0-0130-4b93-bb7e-abe7d665ed2c';
@@ -415,7 +320,7 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
*
* @uses ProductCategoryAttributesController::edit
*/
public function testEditPutLoggedInFailure(): void
public function testEditPutFailure(): void
{
$this->loginUserByRole('admin');
$id = '37078cf0-0130-4b93-bb7e-abe7d665ed2c';
@@ -439,34 +344,6 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
// assert save failed below
}
/**
* Test delete method
*
* Tests the delete action with an unauthenticated user (not logged in)
*
* @return void
* @throws Exception
*
* @uses ProductCategoryAttributesController::delete
*/
public function testDeleteUnauthenticated(): void
{
$cntBefore = $this->ProductCategoryAttributes->find()->count();
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'delete',
'37078cf0-0130-4b93-bb7e-abe7d665ed2c',
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
$cntAfter = $this->ProductCategoryAttributes->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test delete method
*
@@ -477,7 +354,7 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
*
* @uses ProductCategoryAttributesController::delete
*/
public function testDeleteLoggedIn(): void
public function testDelete(): void
{
$cntBefore = $this->ProductCategoryAttributes->find()->count();

View File

@@ -62,28 +62,6 @@ class ProductsControllerTest extends BaseControllerTest
parent::tearDown();
}
/**
* Test index method
*
* Tests the index action with an unauthenticated user (not logged in)
*
* @return void
* @throws Exception
*
* @uses ProductsController::index
*/
public function testIndexGetUnauthenticated(): void
{
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test index method
*
@@ -94,7 +72,7 @@ class ProductsControllerTest extends BaseControllerTest
*
* @uses ProductsController::index
*/
public function testIndexGetLoggedIn(): void
public function testIndexGet(): void
{
$this->loginUserByRole('admin');
$url = [
@@ -106,30 +84,6 @@ class ProductsControllerTest extends BaseControllerTest
$this->assertResponseCode(200);
}
/**
* Test view method
*
* Tests the view action with an unauthenticated user (not logged in)
*
* @return void
* @throws Exception
*
* @uses ProductsController::view
*/
public function testViewGetUnauthenticated(): void
{
$id = 'cfc98a9a-29b2-44c8-b587-8156adc05317';
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test view method
*
@@ -140,7 +94,7 @@ class ProductsControllerTest extends BaseControllerTest
*
* @uses ProductsController::view
*/
public function testViewGetLoggedIn(): void
public function testViewGet(): void
{
$id = 'cfc98a9a-29b2-44c8-b587-8156adc05317';
$this->loginUserByRole('admin');
@@ -154,32 +108,6 @@ class ProductsControllerTest extends BaseControllerTest
$this->assertResponseCode(200);
}
/**
* Test add method
*
* Tests the add action with an unauthenticated user (not logged in)
*
* @return void
* @throws Exception
*
* @uses ProductsController::add
*/
public function testAddGetUnauthenticated(): void
{
$cntBefore = $this->Products->find()->count();
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
$cntAfter = $this->Products->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test add method
*
@@ -190,7 +118,7 @@ class ProductsControllerTest extends BaseControllerTest
*
* @uses ProductsController::add
*/
public function testAddGetLoggedIn(): void
public function testAddGet(): void
{
$cntBefore = $this->Products->find()->count();
@@ -217,41 +145,7 @@ class ProductsControllerTest extends BaseControllerTest
*
* @uses ProductsController::add
*/
public function testAddPostLoggedInSuccess(): void
{
$cntBefore = $this->Products->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'add',
];
$data = [
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'name' => '16AWG WIRE RED',
'product_type_id' => 1,
];
$this->post($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('products');
$cntAfter = $this->Products->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
}
/**
* Test add method
*
* Tests a POST request to the add action with a logged in user
*
* @return void
* @throws Exception
*
* @uses ProductsController::add
*/
public function testAddPostLoggedInFailure(): void
public function testAddPostFailure(): void
{
$cntBefore = $this->Products->find()->count();
@@ -274,29 +168,6 @@ class ProductsControllerTest extends BaseControllerTest
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test edit method
*
* Tests the edit action with an unauthenticated user (not logged in)
*
* @return void
* @throws Exception
*
* @uses ProductsController::edit
*/
public function testEditGetUnauthenticated(): void
{
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'edit',
'cfc98a9a-29b2-44c8-b587-8156adc05317',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test edit method
*
@@ -307,7 +178,7 @@ class ProductsControllerTest extends BaseControllerTest
*
* @uses ProductsController::edit
*/
public function testEditGetLoggedIn(): void
public function testEditGet(): void
{
$this->loginUserByRole('admin');
$url = [
@@ -330,7 +201,7 @@ class ProductsControllerTest extends BaseControllerTest
*
* @uses ProductsController::edit
*/
public function testEditPutLoggedInSuccess(): void
public function testEditPutSuccess(): void
{
$this->loginUserByRole('admin');
$id = 'cfc98a9a-29b2-44c8-b587-8156adc05317';
@@ -368,7 +239,7 @@ class ProductsControllerTest extends BaseControllerTest
*
* @uses ProductsController::edit
*/
public function testEditPutLoggedInFailure(): void
public function testEditPutFailure(): void
{
$this->loginUserByRole('admin');
$id = 'cfc98a9a-29b2-44c8-b587-8156adc05317';
@@ -393,34 +264,6 @@ class ProductsControllerTest extends BaseControllerTest
// assert save failed below
}
/**
* Test delete method
*
* Tests the delete action with an unauthenticated user (not logged in)
*
* @return void
* @throws Exception
*
* @uses ProductsController::delete
*/
public function testDeleteUnauthenticated(): void
{
$cntBefore = $this->Products->find()->count();
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'delete',
'cfc98a9a-29b2-44c8-b587-8156adc05317',
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
$cntAfter = $this->Products->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test delete method
*
@@ -431,7 +274,7 @@ class ProductsControllerTest extends BaseControllerTest
*
* @uses ProductsController::delete
*/
public function testDeleteLoggedIn(): void
public function testDelete(): void
{
$cntBefore = $this->Products->find()->count();