remove external product catalogs and join table for external product catalogs and product catalogs, out of scope of plugin
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Test\Fixture;
|
||||
|
||||
use Cake\TestSuite\Fixture\TestFixture;
|
||||
|
||||
/**
|
||||
* ExternalProductCatalogsFixture
|
||||
*/
|
||||
class ExternalProductCatalogsFixture extends TestFixture {
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void {
|
||||
$this->records = [
|
||||
[
|
||||
'id' => '115153f3-2f59-4234-8ff8-e1b205769999',
|
||||
'base_url' => 'http://localhost:8766',
|
||||
'api_url' => 'http://localhost:8766/api',
|
||||
'created' => '2024-11-22 09:39:37',
|
||||
'deleted' => null,
|
||||
],
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Test\Fixture;
|
||||
|
||||
use Cake\TestSuite\Fixture\TestFixture;
|
||||
|
||||
/**
|
||||
* ExternalProductCatalogsProductCatalogsFixture
|
||||
*/
|
||||
class ExternalProductCatalogsProductCatalogsFixture extends TestFixture {
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void {
|
||||
$this->records = [
|
||||
[
|
||||
'id' => 1,
|
||||
'external_product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205769999',
|
||||
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
|
||||
'created' => '2024-11-22 09:39:37',
|
||||
'enabled' => false,
|
||||
'deleted' => null,
|
||||
],
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,320 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Test\TestCase\Controller;
|
||||
|
||||
use Cake\Log\Log;
|
||||
use Cake\ORM\TableRegistry;
|
||||
use CakeProducts\Controller\ExternalProductCatalogsController;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ExternalProductCatalogsController Test Case
|
||||
*/
|
||||
#[CoversClass(ExternalProductCatalogsController::class)]
|
||||
class ExternalProductCatalogsControllerTest extends BaseControllerTest {
|
||||
|
||||
/**
|
||||
* Test subject table
|
||||
*
|
||||
* @var \CakeProducts\Model\Table\ExternalProductCatalogsTable|\Cake\ORM\Table
|
||||
*/
|
||||
protected $ExternalProductCatalogs;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeProducts.ExternalProductCatalogs',
|
||||
'plugin.CakeProducts.ExternalProductCatalogsProductCatalogs',
|
||||
'plugin.CakeProducts.ProductCatalogs',
|
||||
];
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
// $this->enableCsrfToken();
|
||||
// $this->enableSecurityToken();
|
||||
$this->disableErrorHandlerMiddleware();
|
||||
$this->ExternalProductCatalogs = $this->getTableLocator()->get('CakeProducts.ExternalProductCatalogs');
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void {
|
||||
unset($this->ExternalProductCatalogs);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test index method
|
||||
*
|
||||
* Tests the index action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::index()
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGet(): void {
|
||||
Log::debug('inside testIndexGet ExternalProductCatalogsControllerTest');
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ExternalProductCatalogs',
|
||||
'action' => 'index',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test view method
|
||||
*
|
||||
* Tests the view action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::view()
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGet(): void {
|
||||
$id = '115153f3-2f59-4234-8ff8-e1b205769999';
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ExternalProductCatalogs',
|
||||
'action' => 'view',
|
||||
$id,
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test add method
|
||||
*
|
||||
* Tests the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::add()
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddGet(): void {
|
||||
$cntBefore = $this->ExternalProductCatalogs->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ExternalProductCatalogs',
|
||||
'action' => 'add',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
|
||||
$cntAfter = $this->ExternalProductCatalogs->find()->count();
|
||||
$this->assertEquals($cntBefore, $cntAfter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test add method
|
||||
*
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::add()
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostSuccess(): void {
|
||||
$linksTable = TableRegistry::getTableLocator()->get('CakeProducts.ExternalProductCatalogsProductCatalogs');
|
||||
$cntBefore = $this->ExternalProductCatalogs->find()->count();
|
||||
$linksBefore = $linksTable->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ExternalProductCatalogs',
|
||||
'action' => 'add',
|
||||
];
|
||||
$data = [
|
||||
'base_url' => 'http://localhost:8766',
|
||||
'api_url' => 'http://localhost:8766/api/v1/',
|
||||
'enabled' => true,
|
||||
'external_product_catalogs_product_catalogs' => [
|
||||
['product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428'],
|
||||
],
|
||||
];
|
||||
$this->post($url, $data);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('external-product-catalogs');
|
||||
|
||||
$cntAfter = $this->ExternalProductCatalogs->find()->count();
|
||||
$linksAfter = $linksTable->find()->count();
|
||||
|
||||
$this->assertEquals($cntBefore + 1, $cntAfter);
|
||||
$this->assertEquals($linksBefore + 1, $linksAfter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test add method
|
||||
*
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::add()
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostFailure(): void {
|
||||
$cntBefore = $this->ExternalProductCatalogs->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ExternalProductCatalogs',
|
||||
'action' => 'add',
|
||||
];
|
||||
$data = [
|
||||
'product_catalog_id' => 999999,
|
||||
'base_url' => '',
|
||||
'api_url' => 'http://localhost:8766/api/v1/',
|
||||
'enabled' => true,
|
||||
];
|
||||
$this->post($url, $data);
|
||||
$this->assertResponseCode(200);
|
||||
|
||||
$cntAfter = $this->ExternalProductCatalogs->find()->count();
|
||||
$this->assertEquals($cntBefore, $cntAfter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test edit method
|
||||
*
|
||||
* Tests the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::edit()
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditGet(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ExternalProductCatalogs',
|
||||
'action' => 'edit',
|
||||
'115153f3-2f59-4234-8ff8-e1b205769999',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test edit method
|
||||
*
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::edit()
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutSuccess(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$id = '115153f3-2f59-4234-8ff8-e1b205769999';
|
||||
$before = $this->ExternalProductCatalogs->get($id);
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ExternalProductCatalogs',
|
||||
'action' => 'edit',
|
||||
$id,
|
||||
];
|
||||
$data = [
|
||||
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
|
||||
'base_url' => 'http://localhost:8766',
|
||||
'api_url' => 'http://localhost:8766/api/v1/',
|
||||
'enabled' => true,
|
||||
];
|
||||
$this->put($url, $data);
|
||||
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('external-product-catalogs');
|
||||
|
||||
$after = $this->ExternalProductCatalogs->get($id);
|
||||
// assert saved properly below
|
||||
}
|
||||
|
||||
/**
|
||||
* Test edit method
|
||||
*
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::edit()
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutFailure(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$id = '115153f3-2f59-4234-8ff8-e1b205769999';
|
||||
$before = $this->ExternalProductCatalogs->get($id);
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ExternalProductCatalogs',
|
||||
'action' => 'edit',
|
||||
$id,
|
||||
];
|
||||
$data = [
|
||||
'product_catalog_id' => 9999999,
|
||||
'base_url' => '',
|
||||
'api_url' => 'http://localhost:8766/api/v1/',
|
||||
'enabled' => true,
|
||||
];
|
||||
$this->put($url, $data);
|
||||
$this->assertResponseCode(200);
|
||||
$after = $this->ExternalProductCatalogs->get($id);
|
||||
|
||||
// assert save failed below
|
||||
}
|
||||
|
||||
/**
|
||||
* Test delete method
|
||||
*
|
||||
* Tests the delete action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::delete()
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDelete(): void {
|
||||
$cntBefore = $this->ExternalProductCatalogs->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ExternalProductCatalogs',
|
||||
'action' => 'delete',
|
||||
'115153f3-2f59-4234-8ff8-e1b205769999',
|
||||
];
|
||||
$this->delete($url);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('external-product-catalogs');
|
||||
|
||||
$cntAfter = $this->ExternalProductCatalogs->find()->count();
|
||||
$this->assertEquals($cntBefore - 1, $cntAfter);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Test\TestCase\Controller;
|
||||
|
||||
use CakeProducts\Controller\ExternalProductCatalogsProductCatalogsController;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ExternalProductCatalogsProductCatalogsController Test Case
|
||||
*/
|
||||
#[CoversClass(ExternalProductCatalogsProductCatalogsController::class)]
|
||||
class ExternalProductCatalogsProductCatalogsControllerTest extends BaseControllerTest {
|
||||
|
||||
/**
|
||||
* Test subject table
|
||||
*
|
||||
* @var \CakeProducts\Model\Table\ExternalProductCatalogsProductCatalogsTable|\Cake\ORM\Table
|
||||
*/
|
||||
protected $ExternalProductCatalogsProductCatalogs;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeProducts.ExternalProductCatalogsProductCatalogs',
|
||||
'plugin.CakeProducts.ExternalProductCatalogs',
|
||||
'plugin.CakeProducts.ProductCatalogs',
|
||||
];
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
// $this->enableCsrfToken();
|
||||
// $this->enableSecurityToken();
|
||||
$this->disableErrorHandlerMiddleware();
|
||||
$this->ExternalProductCatalogsProductCatalogs = $this->getTableLocator()->get('CakeProducts.ExternalProductCatalogsProductCatalogs');
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void {
|
||||
unset($this->ExternalProductCatalogsProductCatalogs);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test add method
|
||||
*
|
||||
* Tests the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsProductCatalogsController::add()
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddGet(): void {
|
||||
$cntBefore = $this->ExternalProductCatalogsProductCatalogs->find()->count();
|
||||
|
||||
// $this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ExternalProductCatalogsProductCatalogs',
|
||||
'action' => 'add',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
|
||||
$cntAfter = $this->ExternalProductCatalogsProductCatalogs->find()->count();
|
||||
$this->assertEquals($cntBefore, $cntAfter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test delete method
|
||||
*
|
||||
* Tests the delete action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsProductCatalogsController::delete()
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDelete(): void {
|
||||
$cntBeforeWithTrashed = $this->ExternalProductCatalogsProductCatalogs->find('withTrashed')->count();
|
||||
$cntBefore = $this->ExternalProductCatalogsProductCatalogs->find()->count();
|
||||
|
||||
// $this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ExternalProductCatalogsProductCatalogs',
|
||||
'action' => 'delete',
|
||||
1,
|
||||
];
|
||||
$this->delete($url);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('external-product-catalogs');
|
||||
|
||||
$cntAfterWithTrashed = $this->ExternalProductCatalogsProductCatalogs->find('withTrashed')->count();
|
||||
$cntAfter = $this->ExternalProductCatalogsProductCatalogs->find()->count();
|
||||
$this->assertEquals($cntBefore - 1, $cntAfter);
|
||||
$this->assertEquals($cntBeforeWithTrashed, $cntAfterWithTrashed);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Test\TestCase\Model\Table;
|
||||
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Model\Table\ExternalProductCatalogsTable;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Model\Table\ExternalProductCatalogsTable Test Case
|
||||
*/
|
||||
#[CoversClass(ExternalProductCatalogsTable::class)]
|
||||
class ExternalProductCatalogsTableTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var \CakeProducts\Model\Table\ExternalProductCatalogsTable
|
||||
*/
|
||||
protected $ExternalProductCatalogs;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeProducts.ExternalProductCatalogs',
|
||||
'plugin.CakeProducts.ExternalProductCatalogsProductCatalogs',
|
||||
'plugin.CakeProducts.ProductCatalogs',
|
||||
];
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('ExternalProductCatalogs') ? [] : ['className' => ExternalProductCatalogsTable::class];
|
||||
$this->ExternalProductCatalogs = $this->getTableLocator()->get('ExternalProductCatalogs', $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void {
|
||||
unset($this->ExternalProductCatalogs);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* TestInitialize method
|
||||
*
|
||||
* @uses \CakeProducts\Model\Table\ExternalProductCatalogsTable::initialize
|
||||
* @return void
|
||||
*/
|
||||
public function testInitialize(): void {
|
||||
// verify all associations loaded
|
||||
$expectedAssociations = [
|
||||
'ProductCatalogs',
|
||||
'ExternalProductCatalogsProductCatalogs',
|
||||
];
|
||||
$associations = $this->ExternalProductCatalogs->associations();
|
||||
|
||||
$this->assertCount(count($expectedAssociations), $associations);
|
||||
foreach ($expectedAssociations as $expectedAssociation) {
|
||||
$this->assertTrue($this->ExternalProductCatalogs->hasAssociation($expectedAssociation));
|
||||
}
|
||||
|
||||
// verify all behaviors loaded
|
||||
$expectedBehaviors = [
|
||||
'Timestamp',
|
||||
'Trash',
|
||||
];
|
||||
$behaviors = $this->ExternalProductCatalogs->behaviors();
|
||||
|
||||
$this->assertCount(count($expectedBehaviors), $behaviors);
|
||||
foreach ($expectedBehaviors as $expectedBehavior) {
|
||||
$this->assertTrue($this->ExternalProductCatalogs->hasBehavior($expectedBehavior));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test validationDefault method
|
||||
*
|
||||
* @uses \CakeProducts\Model\Table\ExternalProductCatalogsTable::validationDefault
|
||||
* @return void
|
||||
*/
|
||||
public function testValidationDefault(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test buildRules method
|
||||
*
|
||||
* @uses \CakeProducts\Model\Table\ExternalProductCatalogsTable::buildRules
|
||||
* @return void
|
||||
*/
|
||||
public function testBuildRules(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,7 +27,6 @@ class ProductCatalogsTableTest extends TestCase {
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeProducts.ProductCatalogs',
|
||||
'plugin.CakeProducts.ExternalProductCatalogsProductCatalogs',
|
||||
'plugin.CakeProducts.ProductCategories',
|
||||
];
|
||||
|
||||
@@ -63,7 +62,6 @@ class ProductCatalogsTableTest extends TestCase {
|
||||
// verify all associations loaded
|
||||
$expectedAssociations = [
|
||||
'ProductCategories',
|
||||
'ExternalProductCatalogs',
|
||||
];
|
||||
$associations = $this->ProductCatalogs->associations();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user