test fixes product category variatns - trying to show attribute type id which isnt valid field on that table

This commit is contained in:
Brandon Shipley 2025-09-01 00:10:07 -07:00
parent 9636cc9091
commit 155095c25c
Signed by: bmfs
GPG Key ID: 14E38571D8BB0DE4
3 changed files with 10 additions and 11 deletions

View File

@ -1,8 +1,9 @@
<?php <?php
/** /**
* @var \App\View\AppView $this * @var \App\View\AppView $this
* @var iterable<\App\Model\Entity\ProductCategoryVariant> $productCategoryVariants * @var iterable<\App\Model\Entity\ProductCategoryVariant>|iterable<\Cake\ORM\Entity> $productCategoryVariants
*/ */
?> ?>
<div class="productCategoryVariants index content"> <div class="productCategoryVariants index content">
<?= $this->Html->link(__('New Product Category Variant'), ['action' => 'add'], ['class' => 'button float-right']) ?> <?= $this->Html->link(__('New Product Category Variant'), ['action' => 'add'], ['class' => 'button float-right']) ?>
@ -15,7 +16,6 @@
<th><?= $this->Paginator->sort('name') ?></th> <th><?= $this->Paginator->sort('name') ?></th>
<th><?= $this->Paginator->sort('product_category_id') ?></th> <th><?= $this->Paginator->sort('product_category_id') ?></th>
<th><?= $this->Paginator->sort('product_id') ?></th> <th><?= $this->Paginator->sort('product_id') ?></th>
<th><?= $this->Paginator->sort('attribute_type_id') ?></th>
<th><?= $this->Paginator->sort('enabled') ?></th> <th><?= $this->Paginator->sort('enabled') ?></th>
<th><?= 'Options' ?></th> <th><?= 'Options' ?></th>
<th class="actions"><?= __('Actions') ?></th> <th class="actions"><?= __('Actions') ?></th>
@ -23,12 +23,12 @@
</thead> </thead>
<tbody> <tbody>
<?php foreach ($productCategoryVariants as $productCategoryVariant): ?> <?php foreach ($productCategoryVariants as $productCategoryVariant): ?>
<tr> <tr>
<td><?= h($productCategoryVariant->id) ?></td> <td><?= h($productCategoryVariant->id) ?></td>
<td><?= h($productCategoryVariant->name) ?></td> <td><?= h($productCategoryVariant->name) ?></td>
<td><?= $productCategoryVariant->hasValue('product_category') ? $this->Html->link($productCategoryVariant->product_category->name, ['controller' => 'ProductCategories', 'action' => 'view', $productCategoryVariant->product_category->id]) : '' ?></td> <td><?= $productCategoryVariant->hasValue('product_category') ? $this->Html->link($productCategoryVariant->product_category->name, ['controller' => 'ProductCategories', 'action' => 'view', $productCategoryVariant->product_category->id]) : '' ?></td>
<td><?= $productCategoryVariant->hasValue('product') ? $this->Html->link($productCategoryVariant->product->name, ['controller' => 'Products', 'action' => 'view', $productCategoryVariant->product->id]) : '' ?></td> <td><?= $productCategoryVariant->hasValue('product') ? $this->Html->link($productCategoryVariant->product->name, ['controller' => 'Products', 'action' => 'view', $productCategoryVariant->product->id]) : '' ?></td>
<td><?= $this->Number->format($productCategoryVariant->attribute_type_id) ?></td>
<td><?= h($productCategoryVariant->enabled) ?></td> <td><?= h($productCategoryVariant->enabled) ?></td>
<td> <td>
<small> <small>

View File

@ -34,10 +34,6 @@
<th><?= __('Product') ?></th> <th><?= __('Product') ?></th>
<td><?= $productCategoryVariant->hasValue('product') ? $this->Html->link($productCategoryVariant->product->name, ['controller' => 'Products', 'action' => 'view', $productCategoryVariant->product->id]) : '' ?></td> <td><?= $productCategoryVariant->hasValue('product') ? $this->Html->link($productCategoryVariant->product->name, ['controller' => 'Products', 'action' => 'view', $productCategoryVariant->product->id]) : '' ?></td>
</tr> </tr>
<tr>
<th><?= __('Attribute Type Id') ?></th>
<td><?= $this->Number->format($productCategoryVariant->attribute_type_id) ?></td>
</tr>
<tr> <tr>
<th><?= __('Enabled') ?></th> <th><?= __('Enabled') ?></th>
<td><?= $productCategoryVariant->enabled ? __('Yes') : __('No'); ?></td> <td><?= $productCategoryVariant->enabled ? __('Yes') : __('No'); ?></td>

View File

@ -3,9 +3,9 @@ declare(strict_types=1);
namespace CakeProducts\Test\TestCase\Controller; namespace CakeProducts\Test\TestCase\Controller;
use Cake\ORM\Table;
use CakeProducts\Controller\ProductCategoryVariantsController; use CakeProducts\Controller\ProductCategoryVariantsController;
use Cake\TestSuite\IntegrationTestTrait; use CakeProducts\Model\Table\ProductCategoryAttributesTable;
use Cake\TestSuite\TestCase;
use CakeProducts\Model\Table\ProductCategoryVariantOptionsTable; use CakeProducts\Model\Table\ProductCategoryVariantOptionsTable;
use CakeProducts\Model\Table\ProductCategoryVariantsTable; use CakeProducts\Model\Table\ProductCategoryVariantsTable;
use PHPUnit\Exception; use PHPUnit\Exception;
@ -51,8 +51,11 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->ProductCategoryVariants = $this->getTableLocator()->get('ProductCategoryVariants'); $config = $this->getTableLocator()->exists('ProductCategoryVariants') ? [] : ['className' => ProductCategoryVariantsTable::class];
$this->ProductCategoryVariantOptions = $this->getTableLocator()->get('ProductCategoryVariantOptions'); $this->ProductCategoryVariants = $this->getTableLocator()->get('ProductCategoryVariants', $config);
$config = $this->getTableLocator()->exists('ProductCategoryVariantOptions') ? [] : ['className' => ProductCategoryVariantOptionsTable::class];
$this->ProductCategoryVariantOptions = $this->getTableLocator()->get('ProductCategoryVariantOptions', $config);
} }
/** /**