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,56 +0,0 @@
|
|||||||
<?php
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
use Migrations\BaseMigration;
|
|
||||||
|
|
||||||
class CreateExternalProductCatalogs extends BaseMigration {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Change Method.
|
|
||||||
*
|
|
||||||
* More information on this method is available here:
|
|
||||||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function change(): void {
|
|
||||||
$table = $this->table('external_product_catalogs', ['id' => false, 'primary_key' => ['id']]);
|
|
||||||
$table->addColumn('id', 'uuid', [
|
|
||||||
'default' => null,
|
|
||||||
'null' => false,
|
|
||||||
]);
|
|
||||||
$table->addColumn('product_catalog_id', 'uuid', [
|
|
||||||
'default' => null,
|
|
||||||
'null' => false,
|
|
||||||
]);
|
|
||||||
$table->addColumn('base_url', 'string', [
|
|
||||||
'default' => null,
|
|
||||||
'limit' => 255,
|
|
||||||
'null' => false,
|
|
||||||
]);
|
|
||||||
$table->addColumn('api_url', 'string', [
|
|
||||||
'default' => null,
|
|
||||||
'limit' => 255,
|
|
||||||
'null' => false,
|
|
||||||
]);
|
|
||||||
$table->addColumn('created', 'datetime', [
|
|
||||||
'default' => null,
|
|
||||||
'null' => false,
|
|
||||||
]);
|
|
||||||
$table->addColumn('deleted', 'datetime', [
|
|
||||||
'default' => null,
|
|
||||||
'null' => true,
|
|
||||||
]);
|
|
||||||
$table->addColumn('enabled', 'boolean', [
|
|
||||||
'default' => null,
|
|
||||||
'null' => false,
|
|
||||||
]);
|
|
||||||
$table->addIndex([
|
|
||||||
'product_catalog_id',
|
|
||||||
], [
|
|
||||||
'name' => 'BY_PRODUCT_CATALOG_ID',
|
|
||||||
'unique' => false,
|
|
||||||
]);
|
|
||||||
$table->create();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
use Migrations\BaseMigration;
|
|
||||||
|
|
||||||
class RemoveCatalogIdFromExternalProductCatalogs extends BaseMigration {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Change Method.
|
|
||||||
*
|
|
||||||
* More information on this method is available here:
|
|
||||||
* https://book.cakephp.org/migrations/4/en/migrations.html#the-change-method
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function change(): void {
|
|
||||||
$table = $this->table('external_product_catalogs');
|
|
||||||
$table->removeColumn('product_catalog_id');
|
|
||||||
$table->removeColumn('enabled');
|
|
||||||
$table->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
use Migrations\BaseMigration;
|
|
||||||
|
|
||||||
class CreateExternalProductCatalogsProductCatalogs extends BaseMigration {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Change Method.
|
|
||||||
*
|
|
||||||
* More information on this method is available here:
|
|
||||||
* https://book.cakephp.org/migrations/4/en/migrations.html#the-change-method
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function change(): void {
|
|
||||||
$table = $this->table('external_product_catalogs_product_catalogs');
|
|
||||||
$table->addColumn('external_product_catalog_id', 'uuid', [
|
|
||||||
'default' => null,
|
|
||||||
'null' => false,
|
|
||||||
]);
|
|
||||||
$table->addColumn('product_catalog_id', 'uuid', [
|
|
||||||
'default' => null,
|
|
||||||
'null' => false,
|
|
||||||
]);
|
|
||||||
$table->addColumn('created', 'datetime', [
|
|
||||||
'default' => null,
|
|
||||||
'null' => false,
|
|
||||||
]);
|
|
||||||
$table->addColumn('enabled', 'boolean', [
|
|
||||||
'default' => null,
|
|
||||||
'null' => false,
|
|
||||||
]);
|
|
||||||
$table->create();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -48,13 +48,6 @@ class AddSoftDeleteToAllTables extends BaseMigration {
|
|||||||
]);
|
]);
|
||||||
$table->update();
|
$table->update();
|
||||||
|
|
||||||
$table = $this->table('external_product_catalogs_product_catalogs');
|
|
||||||
$table->addColumn('deleted', 'datetime', [
|
|
||||||
'default' => null,
|
|
||||||
'null' => true,
|
|
||||||
]);
|
|
||||||
$table->update();
|
|
||||||
|
|
||||||
$table = $this->table('product_attributes');
|
$table = $this->table('product_attributes');
|
||||||
$table->addColumn('deleted', 'datetime', [
|
$table->addColumn('deleted', 'datetime', [
|
||||||
'default' => null,
|
'default' => null,
|
||||||
|
|||||||
@@ -1,122 +0,0 @@
|
|||||||
<?php
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace CakeProducts\Controller;
|
|
||||||
|
|
||||||
use Cake\Log\Log;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ExternalProductCatalogs Controller
|
|
||||||
*
|
|
||||||
* @property \CakeProducts\Model\Table\ExternalProductCatalogsTable $ExternalProductCatalogs
|
|
||||||
*/
|
|
||||||
class ExternalProductCatalogsController extends AppController {
|
|
||||||
|
|
||||||
// use OverrideTableTrait;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function initialize(): void {
|
|
||||||
parent::initialize(); // TODO: Change the autogenerated stub
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Index method
|
|
||||||
*
|
|
||||||
* @return \Cake\Http\Response|null|void Renders view
|
|
||||||
*/
|
|
||||||
public function index() {
|
|
||||||
$query = $this->fetchTable()->find()
|
|
||||||
->contain(['ProductCatalogs']);
|
|
||||||
$externalProductCatalogs = $this->paginate($query);
|
|
||||||
|
|
||||||
$this->set(compact('externalProductCatalogs'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* View method
|
|
||||||
*
|
|
||||||
* @param string|null $id External Product Catalog id.
|
|
||||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
|
||||||
* @return \Cake\Http\Response|null|void Renders view
|
|
||||||
*/
|
|
||||||
public function view($id = null) {
|
|
||||||
$externalProductCatalog = $this->fetchTable()->get($id, contain: ['ProductCatalogs']);
|
|
||||||
$this->set(compact('externalProductCatalog'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add method
|
|
||||||
*
|
|
||||||
* @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise.
|
|
||||||
*/
|
|
||||||
public function add() {
|
|
||||||
$externalProductCatalog = $this->fetchTable()->newEmptyEntity();
|
|
||||||
if ($this->request->is('post')) {
|
|
||||||
$saveOptions = [
|
|
||||||
'associated' => [
|
|
||||||
'ExternalProductCatalogsProductCatalogs',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
$postData = $this->request->getData();
|
|
||||||
Log::debug(print_r('$postData', true));
|
|
||||||
Log::debug(print_r($postData, true));
|
|
||||||
$externalProductCatalog = $this->fetchTable()->patchEntity($externalProductCatalog, $postData, $saveOptions);
|
|
||||||
if ($this->fetchTable()->save($externalProductCatalog, $saveOptions)) {
|
|
||||||
$this->Flash->success(__('The external product catalog has been saved.'));
|
|
||||||
|
|
||||||
return $this->redirect(['action' => 'index']);
|
|
||||||
}
|
|
||||||
Log::debug(print_r('$externalProductCatalog->getErrors() next - failed /add', true));
|
|
||||||
Log::debug(print_r($externalProductCatalog->getErrors(), true));
|
|
||||||
$this->Flash->error(__('The external product catalog could not be saved. Please, try again.'));
|
|
||||||
}
|
|
||||||
$productCatalogs = $this->fetchTable()->ProductCatalogs->find('list', limit: 200)->all();
|
|
||||||
$this->set(compact('externalProductCatalog', 'productCatalogs'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Edit method
|
|
||||||
*
|
|
||||||
* @param string|null $id External Product Catalog id.
|
|
||||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
|
||||||
* @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
|
|
||||||
*/
|
|
||||||
public function edit($id = null) {
|
|
||||||
$externalProductCatalog = $this->fetchTable()->get($id, contain: []);
|
|
||||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
|
||||||
$externalProductCatalog = $this->fetchTable()->patchEntity($externalProductCatalog, $this->request->getData());
|
|
||||||
if ($this->fetchTable()->save($externalProductCatalog)) {
|
|
||||||
$this->Flash->success(__('The external product catalog has been saved.'));
|
|
||||||
|
|
||||||
return $this->redirect(['action' => 'index']);
|
|
||||||
}
|
|
||||||
Log::debug(print_r('$externalProductCatalog->getErrors() next - failed /edit', true));
|
|
||||||
Log::debug(print_r($externalProductCatalog->getErrors(), true));
|
|
||||||
$this->Flash->error(__('The external product catalog could not be saved. Please, try again.'));
|
|
||||||
}
|
|
||||||
$productCatalogs = $this->fetchTable()->ProductCatalogs->find('list', limit: 200)->all();
|
|
||||||
$this->set(compact('externalProductCatalog', 'productCatalogs'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete method
|
|
||||||
*
|
|
||||||
* @param string|null $id External Product Catalog id.
|
|
||||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
|
||||||
* @return \Cake\Http\Response|null Redirects to index.
|
|
||||||
*/
|
|
||||||
public function delete($id = null) {
|
|
||||||
$this->request->allowMethod(['post', 'delete']);
|
|
||||||
$externalProductCatalog = $this->fetchTable()->get($id);
|
|
||||||
if ($this->fetchTable()->delete($externalProductCatalog)) {
|
|
||||||
$this->Flash->success(__('The external product catalog has been deleted.'));
|
|
||||||
} else {
|
|
||||||
$this->Flash->error(__('The external product catalog could not be deleted. Please, try again.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->redirect(['action' => 'index']);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace CakeProducts\Controller;
|
|
||||||
|
|
||||||
use Cake\Log\Log;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ExternalProductCatalogsProductCatalogs Controller
|
|
||||||
*/
|
|
||||||
class ExternalProductCatalogsProductCatalogsController extends AppController {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add method
|
|
||||||
*
|
|
||||||
* @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise.
|
|
||||||
*/
|
|
||||||
public function add() {
|
|
||||||
Log::debug('inside external product catalogs product catalogs controller add');
|
|
||||||
$productCatalogs = $this->fetchTable('ProductCatalogs')->find('list')->toArray();
|
|
||||||
$this->set(compact('productCatalogs'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete method
|
|
||||||
*
|
|
||||||
* @param string|null $id Customers Contact id.
|
|
||||||
* @throws RecordNotFoundException When record not found.
|
|
||||||
* @return Response|null Redirects to index.
|
|
||||||
*/
|
|
||||||
public function delete($id = null) {
|
|
||||||
$this->request->allowMethod(['post', 'delete']);
|
|
||||||
$externalProductCatalogProductCatalog = $this->fetchTable()->get($id);
|
|
||||||
if ($this->fetchTable()->delete($externalProductCatalogProductCatalog)) {
|
|
||||||
$this->Flash->success(__('The customers contact has been deleted.'));
|
|
||||||
} else {
|
|
||||||
$this->Flash->error(__('The customers contact could not be deleted. Please, try again.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->redirect($this->referer([
|
|
||||||
'controller' => 'ExternalProductCatalogs',
|
|
||||||
'action' => 'view',
|
|
||||||
$externalProductCatalogProductCatalog->external_product_catalog_id,
|
|
||||||
]));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
<?php
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace CakeProducts\Model\Entity;
|
|
||||||
|
|
||||||
use Cake\ORM\Entity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ExternalProductCatalog Entity
|
|
||||||
*
|
|
||||||
* @property int $id
|
|
||||||
* @property string $base_url
|
|
||||||
* @property string $api_url
|
|
||||||
* @property \Cake\I18n\DateTime $created
|
|
||||||
* @property \Cake\I18n\DateTime|null $deleted
|
|
||||||
*
|
|
||||||
* @property ProductCatalog[] $product_catalogs
|
|
||||||
* @property ExternalProductCatalogsProductCatalog[] $external_product_catalogs_product_catalogs
|
|
||||||
*/
|
|
||||||
class ExternalProductCatalog extends Entity {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fields that can be mass assigned using newEntity() or patchEntity().
|
|
||||||
*
|
|
||||||
* Note that when '*' is set to true, this allows all unspecified fields to
|
|
||||||
* be mass assigned. For security purposes, it is advised to set '*' to false
|
|
||||||
* (or remove it), and explicitly make individual fields accessible as needed.
|
|
||||||
*
|
|
||||||
* @var array<string, bool>
|
|
||||||
*/
|
|
||||||
protected array $_accessible = [
|
|
||||||
'base_url' => true,
|
|
||||||
'api_url' => true,
|
|
||||||
'created' => true,
|
|
||||||
'deleted' => true,
|
|
||||||
'enabled' => true,
|
|
||||||
|
|
||||||
// entities
|
|
||||||
'external_product_catalogs_product_catalogs' => true,
|
|
||||||
];
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace CakeProducts\Model\Entity;
|
|
||||||
|
|
||||||
use Cake\ORM\Entity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ExternalProductCatalogsProductCatalog Entity
|
|
||||||
*
|
|
||||||
* @property int $id
|
|
||||||
* @property string $external_product_catalog_id
|
|
||||||
* @property string $product_catalog_id
|
|
||||||
* @property \Cake\I18n\DateTime $created
|
|
||||||
* @property bool $enabled
|
|
||||||
* @property \Cake\I18n\DateTime|null $deleted
|
|
||||||
*
|
|
||||||
* @property ExternalProductCatalog $external_product_catalog
|
|
||||||
* @property ProductCatalog $product_catalog
|
|
||||||
*/
|
|
||||||
class ExternalProductCatalogsProductCatalog extends Entity {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fields that can be mass assigned using newEntity() or patchEntity().
|
|
||||||
*
|
|
||||||
* Note that when '*' is set to true, this allows all unspecified fields to
|
|
||||||
* be mass assigned. For security purposes, it is advised to set '*' to false
|
|
||||||
* (or remove it), and explicitly make individual fields accessible as needed.
|
|
||||||
*
|
|
||||||
* @var array<string, bool>
|
|
||||||
*/
|
|
||||||
protected array $_accessible = [
|
|
||||||
'external_product_catalog_id' => true,
|
|
||||||
'product_catalog_id' => true,
|
|
||||||
'created' => true,
|
|
||||||
'enabled' => true,
|
|
||||||
'deleted' => true,
|
|
||||||
|
|
||||||
// entities
|
|
||||||
'external_product_catalog' => true,
|
|
||||||
'product_catalog' => true,
|
|
||||||
];
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -15,7 +15,6 @@ use Cake\ORM\Entity;
|
|||||||
* @property \Cake\I18n\DateTime|null $deleted
|
* @property \Cake\I18n\DateTime|null $deleted
|
||||||
*
|
*
|
||||||
* @property ProductCategory[] $product_categories
|
* @property ProductCategory[] $product_categories
|
||||||
* @property ExternalProductCatalog[] $external_product_catalogs
|
|
||||||
*/
|
*/
|
||||||
class ProductCatalog extends Entity {
|
class ProductCatalog extends Entity {
|
||||||
|
|
||||||
@@ -36,7 +35,6 @@ class ProductCatalog extends Entity {
|
|||||||
|
|
||||||
// entities
|
// entities
|
||||||
'product_categories' => true,
|
'product_categories' => true,
|
||||||
'external_product_catalogs' => true,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,118 +0,0 @@
|
|||||||
<?php
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace CakeProducts\Model\Table;
|
|
||||||
|
|
||||||
use ArrayObject;
|
|
||||||
use Cake\Core\Configure;
|
|
||||||
use Cake\Event\EventInterface;
|
|
||||||
use Cake\ORM\Behavior\TimestampBehavior;
|
|
||||||
use Cake\ORM\RulesChecker;
|
|
||||||
use Cake\ORM\Table;
|
|
||||||
use Cake\Validation\Validator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ExternalProductCatalogsProductCatalogs Model
|
|
||||||
*
|
|
||||||
* @property ExternalProductCatalogsTable&\Cake\ORM\Association\BelongsTo $ExternalProductCatalogs
|
|
||||||
* @property ProductCatalogsTable&\Cake\ORM\Association\BelongsTo $ProductCatalogs
|
|
||||||
*
|
|
||||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog newEmptyEntity()
|
|
||||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog newEntity(array $data, array $options = [])
|
|
||||||
* @method array<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog> newEntities(array $data, array $options = [])
|
|
||||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
|
|
||||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog findOrCreate($search, ?callable $callback = null, array $options = [])
|
|
||||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
|
|
||||||
* @method array<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog> patchEntities(iterable $entities, array $data, array $options = [])
|
|
||||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog|false save(\Cake\Datasource\EntityInterface $entity, array $options = [])
|
|
||||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = [])
|
|
||||||
* @method iterable<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog>|false saveMany(iterable $entities, array $options = [])
|
|
||||||
* @method iterable<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog> saveManyOrFail(iterable $entities, array $options = [])
|
|
||||||
* @method iterable<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog>|false deleteMany(iterable $entities, array $options = [])
|
|
||||||
* @method iterable<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog> deleteManyOrFail(iterable $entities, array $options = [])
|
|
||||||
*
|
|
||||||
* @mixin TimestampBehavior
|
|
||||||
*/
|
|
||||||
class ExternalProductCatalogsProductCatalogsTable extends Table {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize method
|
|
||||||
*
|
|
||||||
* @param array<string, mixed> $config The configuration for the Table.
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function initialize(array $config): void {
|
|
||||||
parent::initialize($config);
|
|
||||||
|
|
||||||
$this->setTable('external_product_catalogs_product_catalogs');
|
|
||||||
$this->setDisplayField('external_product_catalog_id');
|
|
||||||
$this->setPrimaryKey('id');
|
|
||||||
|
|
||||||
$this->addBehavior('Timestamp');
|
|
||||||
|
|
||||||
$this->setEntityClass(
|
|
||||||
Configure::read('CakeProducts.ExternalProductCatalogsProductCatalogs.entity', 'CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog'),
|
|
||||||
);
|
|
||||||
$this->belongsTo('ExternalProductCatalogs', [
|
|
||||||
'className' => 'CakeProducts.ExternalProductCatalogs',
|
|
||||||
// 'foreignKey' => 'external_product_catalog_id',
|
|
||||||
'joinType' => 'INNER',
|
|
||||||
]);
|
|
||||||
$this->belongsTo('ProductCatalogs', [
|
|
||||||
'className' => 'CakeProducts.ProductCatalogs',
|
|
||||||
// 'foreignKey' => 'product_catalog_id',
|
|
||||||
'joinType' => 'INNER',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->addBehavior('Muffin/Trash.Trash');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default validation rules.
|
|
||||||
*
|
|
||||||
* @param \Cake\Validation\Validator $validator Validator instance.
|
|
||||||
* @return \Cake\Validation\Validator
|
|
||||||
*/
|
|
||||||
public function validationDefault(Validator $validator): Validator {
|
|
||||||
$validator
|
|
||||||
->uuid('external_product_catalog_id')
|
|
||||||
->notEmptyString('external_product_catalog_id');
|
|
||||||
|
|
||||||
$validator
|
|
||||||
->uuid('product_catalog_id')
|
|
||||||
->notEmptyString('product_catalog_id');
|
|
||||||
|
|
||||||
$validator
|
|
||||||
->boolean('enabled');
|
|
||||||
|
|
||||||
$validator
|
|
||||||
->dateTime('deleted')
|
|
||||||
->allowEmptyDateTime('deleted');
|
|
||||||
|
|
||||||
return $validator;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function beforeMarshal(EventInterface $event, ArrayObject $data, ArrayObject $options) {
|
|
||||||
if (!isset($data['enabled'])) {
|
|
||||||
$data['enabled'] = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a rules checker object that will be used for validating
|
|
||||||
* application integrity.
|
|
||||||
*
|
|
||||||
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
|
|
||||||
* @return \Cake\ORM\RulesChecker
|
|
||||||
*/
|
|
||||||
public function buildRules(RulesChecker $rules): RulesChecker {
|
|
||||||
// $rules->add($rules->existsIn(['external_product_catalog_id'], 'ExternalProductCatalogs'), ['errorField' => 'external_product_catalog_id']);
|
|
||||||
// $rules->add($rules->existsIn(['product_catalog_id'], 'ProductCatalogs'), ['errorField' => 'product_catalog_id']);
|
|
||||||
|
|
||||||
return $rules;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
<?php
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace CakeProducts\Model\Table;
|
|
||||||
|
|
||||||
use Cake\Core\Configure;
|
|
||||||
use Cake\ORM\RulesChecker;
|
|
||||||
use Cake\ORM\Table;
|
|
||||||
use Cake\Validation\Validator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ExternalProductCatalogs Model
|
|
||||||
*
|
|
||||||
* @property ProductCatalogsTable&\Cake\ORM\Association\BelongsTo $ProductCatalogs
|
|
||||||
*
|
|
||||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalog newEmptyEntity()
|
|
||||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalog newEntity(array $data, array $options = [])
|
|
||||||
* @method array<\CakeProducts\Model\Entity\ExternalProductCatalog> newEntities(array $data, array $options = [])
|
|
||||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalog get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
|
|
||||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalog findOrCreate($search, ?callable $callback = null, array $options = [])
|
|
||||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalog patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
|
|
||||||
* @method array<\CakeProducts\Model\Entity\ExternalProductCatalog> patchEntities(iterable $entities, array $data, array $options = [])
|
|
||||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalog|false save(\Cake\Datasource\EntityInterface $entity, array $options = [])
|
|
||||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalog saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = [])
|
|
||||||
* @method iterable<\CakeProducts\Model\Entity\ExternalProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ExternalProductCatalog>|false saveMany(iterable $entities, array $options = [])
|
|
||||||
* @method iterable<\CakeProducts\Model\Entity\ExternalProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ExternalProductCatalog> saveManyOrFail(iterable $entities, array $options = [])
|
|
||||||
* @method iterable<\CakeProducts\Model\Entity\ExternalProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ExternalProductCatalog>|false deleteMany(iterable $entities, array $options = [])
|
|
||||||
* @method iterable<\CakeProducts\Model\Entity\ExternalProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ExternalProductCatalog> deleteManyOrFail(iterable $entities, array $options = [])
|
|
||||||
*
|
|
||||||
* @mixin \Cake\ORM\Behavior\TimestampBehavior
|
|
||||||
*/
|
|
||||||
class ExternalProductCatalogsTable extends Table {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize method
|
|
||||||
*
|
|
||||||
* @param array<string, mixed> $config The configuration for the Table.
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function initialize(array $config): void {
|
|
||||||
parent::initialize($config);
|
|
||||||
|
|
||||||
$this->setTable('external_product_catalogs');
|
|
||||||
$this->setDisplayField('base_url');
|
|
||||||
$this->setPrimaryKey('id');
|
|
||||||
|
|
||||||
$this->addBehavior('Timestamp');
|
|
||||||
|
|
||||||
$this->setEntityClass(
|
|
||||||
Configure::read('CakeProducts.ExternalProductCatalogs.entity', 'CakeProducts\Model\Entity\ExternalProductCatalog'),
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->belongsToMany('ProductCatalogs', [
|
|
||||||
'through' => 'ExternalProductCatalogsProductCatalogs',
|
|
||||||
'className' => 'CakeProducts.ProductCatalogs',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->hasMany('ExternalProductCatalogsProductCatalogs', [
|
|
||||||
'foreignKey' => 'external_product_catalog_id',
|
|
||||||
'className' => 'CakeProducts.ExternalProductCatalogsProductCatalogs',
|
|
||||||
'dependent' => true,
|
|
||||||
'cascadeCallbacks' => true,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->addBehavior('Muffin/Trash.Trash');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default validation rules.
|
|
||||||
*
|
|
||||||
* @param \Cake\Validation\Validator $validator Validator instance.
|
|
||||||
* @return \Cake\Validation\Validator
|
|
||||||
*/
|
|
||||||
public function validationDefault(Validator $validator): Validator {
|
|
||||||
$validator
|
|
||||||
->scalar('base_url')
|
|
||||||
->maxLength('base_url', 255)
|
|
||||||
->requirePresence('base_url', 'create')
|
|
||||||
->notEmptyString('base_url');
|
|
||||||
// ->url('base_url');
|
|
||||||
|
|
||||||
$validator
|
|
||||||
->scalar('api_url')
|
|
||||||
->maxLength('api_url', 255)
|
|
||||||
->requirePresence('api_url', 'create')
|
|
||||||
->notEmptyString('api_url');
|
|
||||||
// ->url('api_url');
|
|
||||||
|
|
||||||
$validator
|
|
||||||
->dateTime('deleted')
|
|
||||||
->allowEmptyDateTime('deleted');
|
|
||||||
|
|
||||||
return $validator;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a rules checker object that will be used for validating
|
|
||||||
* application integrity.
|
|
||||||
*
|
|
||||||
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
|
|
||||||
* @return \Cake\ORM\RulesChecker
|
|
||||||
*/
|
|
||||||
public function buildRules(RulesChecker $rules): RulesChecker {
|
|
||||||
return $rules;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -46,10 +46,6 @@ class ProductCatalogsTable extends Table {
|
|||||||
$this->hasMany('ProductCategories', [
|
$this->hasMany('ProductCategories', [
|
||||||
'className' => 'CakeProducts.ProductCategories',
|
'className' => 'CakeProducts.ProductCategories',
|
||||||
]);
|
]);
|
||||||
$this->belongsToMany('ExternalProductCatalogs', [
|
|
||||||
'through' => 'ExternalProductCatalogsProductCatalogs',
|
|
||||||
'className' => 'CakeProducts.ExternalProductCatalogs',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->addBehavior('Muffin/Trash.Trash');
|
$this->addBehavior('Muffin/Trash.Trash');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @var \App\View\AppView $this
|
|
||||||
* @var \Cake\Datasource\EntityInterface $externalProductCatalog
|
|
||||||
* @var \Cake\Collection\CollectionInterface|string[] $productCatalogs
|
|
||||||
*/
|
|
||||||
?>
|
|
||||||
<div class="row">
|
|
||||||
<aside class="column">
|
|
||||||
<div class="side-nav">
|
|
||||||
<h4 class="heading"><?= __('Actions') ?></h4>
|
|
||||||
<?= $this->Html->link(__('List External Product Catalogs'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
|
|
||||||
</div>
|
|
||||||
</aside>
|
|
||||||
<div class="column column-80">
|
|
||||||
<div class="externalProductCatalogs form content">
|
|
||||||
<?= $this->Form->create($externalProductCatalog) ?>
|
|
||||||
<fieldset>
|
|
||||||
<legend><?= __('Add External Product Catalog') ?></legend>
|
|
||||||
<?php
|
|
||||||
echo $this->Form->control('product_catalog_id', ['options' => $productCatalogs]);
|
|
||||||
echo $this->Form->control('base_url');
|
|
||||||
echo $this->Form->control('api_url');
|
|
||||||
echo $this->Form->control('enabled');
|
|
||||||
?>
|
|
||||||
</fieldset>
|
|
||||||
<?= $this->Form->button(__('Submit')) ?>
|
|
||||||
<?= $this->Form->end() ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @var \App\View\AppView $this
|
|
||||||
* @var \Cake\Datasource\EntityInterface $externalProductCatalog
|
|
||||||
* @var string[]|\Cake\Collection\CollectionInterface $productCatalogs
|
|
||||||
*/
|
|
||||||
?>
|
|
||||||
<div class="row">
|
|
||||||
<aside class="column">
|
|
||||||
<div class="side-nav">
|
|
||||||
<h4 class="heading"><?= __('Actions') ?></h4>
|
|
||||||
<?= $this->Form->postLink(
|
|
||||||
__('Delete'),
|
|
||||||
['action' => 'delete', $externalProductCatalog->id],
|
|
||||||
['confirm' => __('Are you sure you want to delete # {0}?', $externalProductCatalog->id), 'class' => 'side-nav-item']
|
|
||||||
) ?>
|
|
||||||
<?= $this->Html->link(__('List External Product Catalogs'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
|
|
||||||
</div>
|
|
||||||
</aside>
|
|
||||||
<div class="column column-80">
|
|
||||||
<div class="externalProductCatalogs form content">
|
|
||||||
<?= $this->Form->create($externalProductCatalog) ?>
|
|
||||||
<fieldset>
|
|
||||||
<legend><?= __('Edit External Product Catalog') ?></legend>
|
|
||||||
<?php
|
|
||||||
echo $this->Form->control('product_catalog_id', ['options' => $productCatalogs]);
|
|
||||||
echo $this->Form->control('base_url');
|
|
||||||
echo $this->Form->control('api_url');
|
|
||||||
echo $this->Form->control('enabled');
|
|
||||||
?>
|
|
||||||
</fieldset>
|
|
||||||
<?= $this->Form->button(__('Submit')) ?>
|
|
||||||
<?= $this->Form->end() ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @var \App\View\AppView $this
|
|
||||||
* @var iterable<\Cake\Datasource\EntityInterface> $externalProductCatalogs
|
|
||||||
*/
|
|
||||||
?>
|
|
||||||
<div class="externalProductCatalogs index content">
|
|
||||||
<?= $this->Html->link(__('New External Product Catalog'), ['action' => 'add'], ['class' => 'button float-right']) ?>
|
|
||||||
<h3><?= __('External Product Catalogs') ?></h3>
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th><?= $this->Paginator->sort('product_catalog_id') ?></th>
|
|
||||||
<th><?= $this->Paginator->sort('base_url') ?></th>
|
|
||||||
<th><?= $this->Paginator->sort('api_url') ?></th>
|
|
||||||
<th><?= $this->Paginator->sort('created') ?></th>
|
|
||||||
<th><?= $this->Paginator->sort('deleted') ?></th>
|
|
||||||
<th><?= $this->Paginator->sort('enabled') ?></th>
|
|
||||||
<th class="actions"><?= __('Actions') ?></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($externalProductCatalogs as $externalProductCatalog): ?>
|
|
||||||
<tr>
|
|
||||||
<td><?= $externalProductCatalog->hasValue('product_catalog') ? $this->Html->link($externalProductCatalog->product_catalog->name, ['controller' => 'ProductCatalogs', 'action' => 'view', $externalProductCatalog->product_catalog->id]) : '' ?></td>
|
|
||||||
<td><?= h($externalProductCatalog->base_url) ?></td>
|
|
||||||
<td><?= h($externalProductCatalog->api_url) ?></td>
|
|
||||||
<td><?= h($externalProductCatalog->created) ?></td>
|
|
||||||
<td><?= h($externalProductCatalog->deleted) ?></td>
|
|
||||||
<td><?= h($externalProductCatalog->enabled) ?></td>
|
|
||||||
<td class="actions">
|
|
||||||
<?= $this->Html->link(__('View'), ['action' => 'view', $externalProductCatalog->id]) ?>
|
|
||||||
<?= $this->Html->link(__('Edit'), ['action' => 'edit', $externalProductCatalog->id]) ?>
|
|
||||||
<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $externalProductCatalog->id], ['confirm' => __('Are you sure you want to delete # {0}?', $externalProductCatalog->id)]) ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="paginator">
|
|
||||||
<ul class="pagination">
|
|
||||||
<?= $this->Paginator->first('<< ' . __('first')) ?>
|
|
||||||
<?= $this->Paginator->prev('< ' . __('previous')) ?>
|
|
||||||
<?= $this->Paginator->numbers() ?>
|
|
||||||
<?= $this->Paginator->next(__('next') . ' >') ?>
|
|
||||||
<?= $this->Paginator->last(__('last') . ' >>') ?>
|
|
||||||
</ul>
|
|
||||||
<p><?= $this->Paginator->counter(__('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')) ?></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @var \App\View\AppView $this
|
|
||||||
* @var \App\Model\Entity\ExternalProductCatalog $externalProductCatalog
|
|
||||||
*/
|
|
||||||
?>
|
|
||||||
<div class="row">
|
|
||||||
<aside class="column">
|
|
||||||
<div class="side-nav">
|
|
||||||
<h4 class="heading"><?= __('Actions') ?></h4>
|
|
||||||
<?= $this->Html->link(__('Edit External Product Catalog'), ['action' => 'edit', $externalProductCatalog->id], ['class' => 'side-nav-item']) ?>
|
|
||||||
<?= $this->Form->postLink(__('Delete External Product Catalog'), ['action' => 'delete', $externalProductCatalog->id], ['confirm' => __('Are you sure you want to delete # {0}?', $externalProductCatalog->id), 'class' => 'side-nav-item']) ?>
|
|
||||||
<?= $this->Html->link(__('List External Product Catalogs'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
|
|
||||||
<?= $this->Html->link(__('New External Product Catalog'), ['action' => 'add'], ['class' => 'side-nav-item']) ?>
|
|
||||||
</div>
|
|
||||||
</aside>
|
|
||||||
<div class="column column-80">
|
|
||||||
<div class="externalProductCatalogs view content">
|
|
||||||
<h3><?= h($externalProductCatalog->base_url) ?></h3>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<th><?= __('Base Url') ?></th>
|
|
||||||
<td><?= h($externalProductCatalog->base_url) ?></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th><?= __('Api Url') ?></th>
|
|
||||||
<td><?= h($externalProductCatalog->api_url) ?></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th><?= __('Id') ?></th>
|
|
||||||
<td><?= $this->Number->format($externalProductCatalog->id) ?></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th><?= __('Created') ?></th>
|
|
||||||
<td><?= h($externalProductCatalog->created) ?></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th><?= __('Deleted') ?></th>
|
|
||||||
<td><?= h($externalProductCatalog->deleted) ?></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<div class="related">
|
|
||||||
<h4><?= __('Related Product Catalogs') ?></h4>
|
|
||||||
<?php if (!empty($externalProductCatalog->product_catalogs)) : ?>
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<th><?= __('Name') ?></th>
|
|
||||||
<th><?= __('Catalog Description') ?></th>
|
|
||||||
<th><?= __('Enabled') ?></th>
|
|
||||||
<th class="actions"><?= __('Actions') ?></th>
|
|
||||||
</tr>
|
|
||||||
<?php foreach ($externalProductCatalog->product_catalogs as $productCatalog) : ?>
|
|
||||||
<tr>
|
|
||||||
<td><?= h($productCatalog->name) ?></td>
|
|
||||||
<td><?= h($productCatalog->catalog_description) ?></td>
|
|
||||||
<td><?= h($productCatalog->_joinData->enabled) ?></td>
|
|
||||||
<td class="actions">
|
|
||||||
<?= $this->Html->link(__('View'), ['controller' => 'ProductCatalogs', 'action' => 'view', $productCatalog->id]) ?>
|
|
||||||
<?= $this->Html->link(__('Edit'), ['controller' => 'ProductCatalogs', 'action' => 'edit', $productCatalog->id]) ?>
|
|
||||||
<?= $this->Form->postLink(__('Delete'), ['controller' => 'ProductCatalogs', 'action' => 'delete', $productCatalog->id], ['confirm' => __('Are you sure you want to delete # {0}?', $productCatalog->id)]) ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @var \App\View\AppView $this
|
|
||||||
* @var \Cake\Collection\CollectionInterface|string[] $productCatalogs
|
|
||||||
*/
|
|
||||||
$this->setLayout('ajax');
|
|
||||||
|
|
||||||
echo $this->element('ExternalProductCatalogs/catalog_form'); ?>
|
|
||||||
@@ -58,38 +58,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="related">
|
|
||||||
<h4><?= __('External Product Catalog API\'s ') ?></h4>
|
|
||||||
<?php if (!empty($productCatalog->external_product_catalogs)) : ?>
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<th><?= __('Name') ?></th>
|
|
||||||
<th><?= __('Category Description') ?></th>
|
|
||||||
<th><?= __('Enabled') ?></th>
|
|
||||||
<th class="actions"><?= __('Actions') ?></th>
|
|
||||||
</tr>
|
|
||||||
<?php foreach ($productCatalog->external_product_catalogs as $externalProductCatalog) : ?>
|
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @var \CakeProducts\Model\Entity\ExternalProductCatalog $externalProductCatalog
|
|
||||||
*/
|
|
||||||
?>
|
|
||||||
<tr>
|
|
||||||
<td><?= h($externalProductCatalog->base_url) ?></td>
|
|
||||||
<td><?= h($externalProductCatalog->api_url) ?></td>
|
|
||||||
<td><?= h($externalProductCatalog->_joinData->enabled) ?></td>
|
|
||||||
<td class="actions">
|
|
||||||
<?= $this->Html->link(__('View'), ['controller' => 'ExternalProductCatalogs', 'action' => 'view', $externalProductCatalog->id]) ?>
|
|
||||||
<?= $this->Html->link(__('Edit'), ['controller' => 'ExternalProductCatalogs', 'action' => 'edit', $externalProductCatalog->id]) ?>
|
|
||||||
<?= $this->Form->postLink(__('Delete'), ['controller' => 'ExternalProductCatalogsProductCatalogs', 'action' => 'delete', $externalProductCatalog->_joinData->id], ['confirm' => __('Are you sure you want to delete # {0}?', $externalProductCatalog->id)]) ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -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 = [
|
protected array $fixtures = [
|
||||||
'plugin.CakeProducts.ProductCatalogs',
|
'plugin.CakeProducts.ProductCatalogs',
|
||||||
'plugin.CakeProducts.ExternalProductCatalogsProductCatalogs',
|
|
||||||
'plugin.CakeProducts.ProductCategories',
|
'plugin.CakeProducts.ProductCategories',
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -63,7 +62,6 @@ class ProductCatalogsTableTest extends TestCase {
|
|||||||
// verify all associations loaded
|
// verify all associations loaded
|
||||||
$expectedAssociations = [
|
$expectedAssociations = [
|
||||||
'ProductCategories',
|
'ProductCategories',
|
||||||
'ExternalProductCatalogs',
|
|
||||||
];
|
];
|
||||||
$associations = $this->ProductCatalogs->associations();
|
$associations = $this->ProductCatalogs->associations();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user