from main app code base
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user