diff --git a/config/Migrations/20241122070040_CreateExternalProductCatalogs.php b/config/Migrations/20241122070040_CreateExternalProductCatalogs.php deleted file mode 100644 index 339a617..0000000 --- a/config/Migrations/20241122070040_CreateExternalProductCatalogs.php +++ /dev/null @@ -1,56 +0,0 @@ -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(); - } - -} diff --git a/config/Migrations/20250331012424_RemoveCatalogIdFromExternalProductCatalogs.php b/config/Migrations/20250331012424_RemoveCatalogIdFromExternalProductCatalogs.php deleted file mode 100644 index f575938..0000000 --- a/config/Migrations/20250331012424_RemoveCatalogIdFromExternalProductCatalogs.php +++ /dev/null @@ -1,22 +0,0 @@ -table('external_product_catalogs'); - $table->removeColumn('product_catalog_id'); - $table->removeColumn('enabled'); - $table->update(); - } - -} diff --git a/config/Migrations/20250331030759_CreateExternalProductCatalogsProductCatalogs.php b/config/Migrations/20250331030759_CreateExternalProductCatalogsProductCatalogs.php deleted file mode 100644 index ba8266d..0000000 --- a/config/Migrations/20250331030759_CreateExternalProductCatalogsProductCatalogs.php +++ /dev/null @@ -1,36 +0,0 @@ -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(); - } - -} diff --git a/config/Migrations/20250408080349_AddSoftDeleteToAllTables.php b/config/Migrations/20250408080349_AddSoftDeleteToAllTables.php index d7ad3b9..cdc0191 100644 --- a/config/Migrations/20250408080349_AddSoftDeleteToAllTables.php +++ b/config/Migrations/20250408080349_AddSoftDeleteToAllTables.php @@ -48,13 +48,6 @@ class AddSoftDeleteToAllTables extends BaseMigration { ]); $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->addColumn('deleted', 'datetime', [ 'default' => null, diff --git a/src/Controller/ExternalProductCatalogsController.php b/src/Controller/ExternalProductCatalogsController.php deleted file mode 100644 index f8f6dc3..0000000 --- a/src/Controller/ExternalProductCatalogsController.php +++ /dev/null @@ -1,122 +0,0 @@ -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']); - } - -} diff --git a/src/Controller/ExternalProductCatalogsProductCatalogsController.php b/src/Controller/ExternalProductCatalogsProductCatalogsController.php deleted file mode 100644 index 536afd0..0000000 --- a/src/Controller/ExternalProductCatalogsProductCatalogsController.php +++ /dev/null @@ -1,47 +0,0 @@ -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, - ])); - } - -} diff --git a/src/Model/Entity/ExternalProductCatalog.php b/src/Model/Entity/ExternalProductCatalog.php deleted file mode 100644 index e0f6401..0000000 --- a/src/Model/Entity/ExternalProductCatalog.php +++ /dev/null @@ -1,42 +0,0 @@ - - */ - protected array $_accessible = [ - 'base_url' => true, - 'api_url' => true, - 'created' => true, - 'deleted' => true, - 'enabled' => true, - - // entities - 'external_product_catalogs_product_catalogs' => true, - ]; - -} diff --git a/src/Model/Entity/ExternalProductCatalogsProductCatalog.php b/src/Model/Entity/ExternalProductCatalogsProductCatalog.php deleted file mode 100644 index 8bcee3d..0000000 --- a/src/Model/Entity/ExternalProductCatalogsProductCatalog.php +++ /dev/null @@ -1,44 +0,0 @@ - - */ - 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, - ]; - -} diff --git a/src/Model/Entity/ProductCatalog.php b/src/Model/Entity/ProductCatalog.php index 3cd6341..f4df4b4 100644 --- a/src/Model/Entity/ProductCatalog.php +++ b/src/Model/Entity/ProductCatalog.php @@ -15,7 +15,6 @@ use Cake\ORM\Entity; * @property \Cake\I18n\DateTime|null $deleted * * @property ProductCategory[] $product_categories - * @property ExternalProductCatalog[] $external_product_catalogs */ class ProductCatalog extends Entity { @@ -36,7 +35,6 @@ class ProductCatalog extends Entity { // entities 'product_categories' => true, - 'external_product_catalogs' => true, ]; } diff --git a/src/Model/Table/ExternalProductCatalogsProductCatalogsTable.php b/src/Model/Table/ExternalProductCatalogsProductCatalogsTable.php deleted file mode 100644 index 796778a..0000000 --- a/src/Model/Table/ExternalProductCatalogsProductCatalogsTable.php +++ /dev/null @@ -1,118 +0,0 @@ - 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 $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; - } - -} diff --git a/src/Model/Table/ExternalProductCatalogsTable.php b/src/Model/Table/ExternalProductCatalogsTable.php deleted file mode 100644 index 7f1af0c..0000000 --- a/src/Model/Table/ExternalProductCatalogsTable.php +++ /dev/null @@ -1,107 +0,0 @@ - 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 $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; - } - -} diff --git a/src/Model/Table/ProductCatalogsTable.php b/src/Model/Table/ProductCatalogsTable.php index fdaf3af..b3e244d 100644 --- a/src/Model/Table/ProductCatalogsTable.php +++ b/src/Model/Table/ProductCatalogsTable.php @@ -46,10 +46,6 @@ class ProductCatalogsTable extends Table { $this->hasMany('ProductCategories', [ 'className' => 'CakeProducts.ProductCategories', ]); - $this->belongsToMany('ExternalProductCatalogs', [ - 'through' => 'ExternalProductCatalogsProductCatalogs', - 'className' => 'CakeProducts.ExternalProductCatalogs', - ]); $this->addBehavior('Muffin/Trash.Trash'); } diff --git a/templates/ExternalProductCatalogs/add.php b/templates/ExternalProductCatalogs/add.php deleted file mode 100644 index d7c2add..0000000 --- a/templates/ExternalProductCatalogs/add.php +++ /dev/null @@ -1,31 +0,0 @@ - -
- -
-
- Form->create($externalProductCatalog) ?> -
- - Form->control('product_catalog_id', ['options' => $productCatalogs]); - echo $this->Form->control('base_url'); - echo $this->Form->control('api_url'); - echo $this->Form->control('enabled'); - ?> -
- Form->button(__('Submit')) ?> - Form->end() ?> -
-
-
diff --git a/templates/ExternalProductCatalogs/edit.php b/templates/ExternalProductCatalogs/edit.php deleted file mode 100644 index 7d9c89a..0000000 --- a/templates/ExternalProductCatalogs/edit.php +++ /dev/null @@ -1,36 +0,0 @@ - -
- -
-
- Form->create($externalProductCatalog) ?> -
- - Form->control('product_catalog_id', ['options' => $productCatalogs]); - echo $this->Form->control('base_url'); - echo $this->Form->control('api_url'); - echo $this->Form->control('enabled'); - ?> -
- Form->button(__('Submit')) ?> - Form->end() ?> -
-
-
diff --git a/templates/ExternalProductCatalogs/index.php b/templates/ExternalProductCatalogs/index.php deleted file mode 100644 index 105c0da..0000000 --- a/templates/ExternalProductCatalogs/index.php +++ /dev/null @@ -1,52 +0,0 @@ - $externalProductCatalogs - */ -?> -
- Html->link(__('New External Product Catalog'), ['action' => 'add'], ['class' => 'button float-right']) ?> -

-
- - - - - - - - - - - - - - - - - - - - - - - - - -
Paginator->sort('product_catalog_id') ?>Paginator->sort('base_url') ?>Paginator->sort('api_url') ?>Paginator->sort('created') ?>Paginator->sort('deleted') ?>Paginator->sort('enabled') ?>
hasValue('product_catalog') ? $this->Html->link($externalProductCatalog->product_catalog->name, ['controller' => 'ProductCatalogs', 'action' => 'view', $externalProductCatalog->product_catalog->id]) : '' ?>base_url) ?>api_url) ?>created) ?>deleted) ?>enabled) ?> - Html->link(__('View'), ['action' => 'view', $externalProductCatalog->id]) ?> - Html->link(__('Edit'), ['action' => 'edit', $externalProductCatalog->id]) ?> - Form->postLink(__('Delete'), ['action' => 'delete', $externalProductCatalog->id], ['confirm' => __('Are you sure you want to delete # {0}?', $externalProductCatalog->id)]) ?> -
-
-
-
    - Paginator->first('<< ' . __('first')) ?> - Paginator->prev('< ' . __('previous')) ?> - Paginator->numbers() ?> - Paginator->next(__('next') . ' >') ?> - Paginator->last(__('last') . ' >>') ?> -
-

Paginator->counter(__('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')) ?>

-
-
diff --git a/templates/ExternalProductCatalogs/view.php b/templates/ExternalProductCatalogs/view.php deleted file mode 100644 index 47bd4ac..0000000 --- a/templates/ExternalProductCatalogs/view.php +++ /dev/null @@ -1,71 +0,0 @@ - -
- -
-
-

base_url) ?>

- - - - - - - - - - - - - - - - - - - - - -
base_url) ?>
api_url) ?>
Number->format($externalProductCatalog->id) ?>
created) ?>
deleted) ?>
- -
-
-
diff --git a/templates/ExternalProductCatalogsProductCatalogs/add.php b/templates/ExternalProductCatalogsProductCatalogs/add.php deleted file mode 100644 index c2d5ea0..0000000 --- a/templates/ExternalProductCatalogsProductCatalogs/add.php +++ /dev/null @@ -1,8 +0,0 @@ -setLayout('ajax'); - -echo $this->element('ExternalProductCatalogs/catalog_form'); ?> diff --git a/templates/ProductCatalogs/view.php b/templates/ProductCatalogs/view.php index 070a54f..47fe78a 100644 --- a/templates/ProductCatalogs/view.php +++ b/templates/ProductCatalogs/view.php @@ -58,38 +58,6 @@ - diff --git a/tests/Fixture/ExternalProductCatalogsFixture.php b/tests/Fixture/ExternalProductCatalogsFixture.php deleted file mode 100644 index b931166..0000000 --- a/tests/Fixture/ExternalProductCatalogsFixture.php +++ /dev/null @@ -1,31 +0,0 @@ -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(); - } - -} diff --git a/tests/Fixture/ExternalProductCatalogsProductCatalogsFixture.php b/tests/Fixture/ExternalProductCatalogsProductCatalogsFixture.php deleted file mode 100644 index 1c66b8c..0000000 --- a/tests/Fixture/ExternalProductCatalogsProductCatalogsFixture.php +++ /dev/null @@ -1,32 +0,0 @@ -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(); - } - -} diff --git a/tests/TestCase/Controller/ExternalProductCatalogsControllerTest.php b/tests/TestCase/Controller/ExternalProductCatalogsControllerTest.php deleted file mode 100644 index c05f5c5..0000000 --- a/tests/TestCase/Controller/ExternalProductCatalogsControllerTest.php +++ /dev/null @@ -1,320 +0,0 @@ - - */ - 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); - } - -} diff --git a/tests/TestCase/Controller/ExternalProductCatalogsProductCatalogsControllerTest.php b/tests/TestCase/Controller/ExternalProductCatalogsProductCatalogsControllerTest.php deleted file mode 100644 index 023e5be..0000000 --- a/tests/TestCase/Controller/ExternalProductCatalogsProductCatalogsControllerTest.php +++ /dev/null @@ -1,114 +0,0 @@ - - */ - 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); - } - -} diff --git a/tests/TestCase/Model/Table/ExternalProductCatalogsTableTest.php b/tests/TestCase/Model/Table/ExternalProductCatalogsTableTest.php deleted file mode 100644 index 897a1c7..0000000 --- a/tests/TestCase/Model/Table/ExternalProductCatalogsTableTest.php +++ /dev/null @@ -1,108 +0,0 @@ - - */ - 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.'); - } - -} diff --git a/tests/TestCase/Model/Table/ProductCatalogsTableTest.php b/tests/TestCase/Model/Table/ProductCatalogsTableTest.php index de425a5..dba18ca 100644 --- a/tests/TestCase/Model/Table/ProductCatalogsTableTest.php +++ b/tests/TestCase/Model/Table/ProductCatalogsTableTest.php @@ -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();