uuids instead of int ids fore xternal product catalogs, test fixes, many to many working now

This commit is contained in:
2025-03-31 01:30:09 -07:00
parent 4c65d23e2b
commit 025017537f
11 changed files with 43 additions and 31 deletions

View File

@@ -32,6 +32,7 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
*/
protected array $fixtures = [
'plugin.CakeProducts.ExternalProductCatalogs',
'plugin.CakeProducts.ExternalProductCatalogsProductCatalogs',
'plugin.CakeProducts.ProductCatalogs',
];
@@ -96,7 +97,7 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
*/
public function testViewGet(): void
{
$id = 1;
$id = '115153f3-2f59-4234-8ff8-e1b205769999';
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
@@ -218,7 +219,7 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'edit',
1,
'115153f3-2f59-4234-8ff8-e1b205769999',
];
$this->get($url);
$this->assertResponseCode(200);
@@ -237,7 +238,7 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
public function testEditPutSuccess(): void
{
$this->loginUserByRole('admin');
$id = 1;
$id = '115153f3-2f59-4234-8ff8-e1b205769999';
$before = $this->ExternalProductCatalogs->get($id);
$url = [
'plugin' => 'CakeProducts',
@@ -273,7 +274,7 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
public function testEditPutFailure(): void
{
$this->loginUserByRole('admin');
$id = 1;
$id = '115153f3-2f59-4234-8ff8-e1b205769999';
$before = $this->ExternalProductCatalogs->get($id);
$url = [
'plugin' => 'CakeProducts',
@@ -313,7 +314,7 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'delete',
1,
'115153f3-2f59-4234-8ff8-e1b205769999',
];
$this->delete($url);
$this->assertResponseCode(302);

View File

@@ -110,7 +110,7 @@ class ExternalProductCatalogsProductCatalogsControllerTest extends BaseControlle
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('externalproductcatalogsproductcatalogs');
$this->assertRedirectContains('external-product-catalogs');
$cntAfter = $this->ExternalProductCatalogsProductCatalogs->find()->count();
$this->assertEquals($cntBefore - 1, $cntAfter);

View File

@@ -3,6 +3,7 @@ declare(strict_types=1);
namespace CakeProducts\Test\TestCase\Model\Table;
use Cake\ORM\Table;
use Cake\TestSuite\TestCase;
use CakeProducts\Model\Table\ExternalProductCatalogsTable;
@@ -14,7 +15,7 @@ class ExternalProductCatalogsTableTest extends TestCase
/**
* Test subject
*
* @var \CakeProducts\Model\Table\ExternalProductCatalogsTable
* @var ExternalProductCatalogsTable
*/
protected $ExternalProductCatalogs;
@@ -25,6 +26,7 @@ class ExternalProductCatalogsTableTest extends TestCase
*/
protected array $fixtures = [
'plugin.CakeProducts.ExternalProductCatalogs',
'plugin.CakeProducts.ExternalProductCatalogsProductCatalogs',
'plugin.CakeProducts.ProductCatalogs',
];
@@ -56,13 +58,14 @@ class ExternalProductCatalogsTableTest extends TestCase
* TestInitialize method
*
* @return void
* @uses \CakeProducts\Model\Table\ExternalProductCatalogsTable::initialize()
* @uses ExternalProductCatalogsTable::initialize
*/
public function testInitialize(): void
{
// verify all associations loaded
$expectedAssociations = [
'ProductCatalogs',
'ExternalProductCatalogsProductCatalogs',
];
$associations = $this->ExternalProductCatalogs->associations();
@@ -87,7 +90,7 @@ class ExternalProductCatalogsTableTest extends TestCase
* Test validationDefault method
*
* @return void
* @uses \CakeProducts\Model\Table\ExternalProductCatalogsTable::validationDefault()
* @uses ExternalProductCatalogsTable::validationDefault
*/
public function testValidationDefault(): void
{
@@ -98,7 +101,7 @@ class ExternalProductCatalogsTableTest extends TestCase
* Test buildRules method
*
* @return void
* @uses \CakeProducts\Model\Table\ExternalProductCatalogsTable::buildRules()
* @uses ExternalProductCatalogsTable::buildRules
*/
public function testBuildRules(): void
{

View File

@@ -26,6 +26,7 @@ class ProductCatalogsTableTest extends TestCase
*/
protected array $fixtures = [
'plugin.CakeProducts.ProductCatalogs',
'plugin.CakeProducts.ExternalProductCatalogsProductCatalogs',
'plugin.CakeProducts.ProductCategories',
];