variants controller tests failing
This commit is contained in:
parent
8bdb329828
commit
b9bf47f385
|
@ -52,7 +52,11 @@ class ProductCategoryVariantsController extends AppController
|
|||
*/
|
||||
public function view($id = null)
|
||||
{
|
||||
$productCategoryVariant = $this->getTable()->get($id, contain: ['ProductCategories', 'Products', 'ProductCategoryVariantOptions']);
|
||||
$productCategoryVariant = $this->getTable()->get($id, contain: [
|
||||
'ProductCategories',
|
||||
'Products',
|
||||
'ProductCategoryVariantOptions',
|
||||
]);
|
||||
$this->set(compact('productCategoryVariant'));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,16 +4,19 @@ declare(strict_types=1);
|
|||
namespace CakeProducts\Controller;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Datasource\Exception\RecordNotFoundException;
|
||||
use Cake\Http\Exception\ForbiddenException;
|
||||
use Cake\Http\Response;
|
||||
use Cake\Utility\Text;
|
||||
use CakeProducts\Controller\AppController;
|
||||
use CakeProducts\Model\Table\ProductPhotosTable;
|
||||
use CheeseCake\Controller\Traits\OverrideTableTrait;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
|
||||
/**
|
||||
* ProductPhotos Controller
|
||||
*
|
||||
* @property \CakeProducts\Model\Table\ProductPhotosTable $ProductPhotos
|
||||
* @property ProductPhotosTable $ProductPhotos
|
||||
*/
|
||||
class ProductPhotosController extends AppController
|
||||
{
|
||||
|
@ -22,12 +25,12 @@ class ProductPhotosController extends AppController
|
|||
/**
|
||||
* Index method
|
||||
*
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
* @return Response|null|void Renders view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$query = $this->getTable()->find()
|
||||
->contain(['Products']);
|
||||
->contain(['Products', 'ProductSkus']);
|
||||
$productPhotos = $this->paginate($query);
|
||||
|
||||
$this->set(compact('productPhotos'));
|
||||
|
@ -37,19 +40,19 @@ class ProductPhotosController extends AppController
|
|||
* View method
|
||||
*
|
||||
* @param string|null $id Product Photo id.
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return Response|null|void Renders view
|
||||
* @throws RecordNotFoundException When record not found.
|
||||
*/
|
||||
public function view($id = null)
|
||||
{
|
||||
$productPhoto = $this->getTable()->get($id, contain: ['Products']);
|
||||
$productPhoto = $this->getTable()->get($id, contain: ['Products', 'ProductSkus']);
|
||||
$this->set(compact('productPhoto'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add method
|
||||
*
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise.
|
||||
* @return Response|null|void Redirects on successful add, renders view otherwise.
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
|
@ -101,16 +104,17 @@ class ProductPhotosController extends AppController
|
|||
$this->Flash->error(__('The product photo could not be saved. Please, try again.'));
|
||||
}
|
||||
$products = $productPhotosTable->Products->find('list', limit: 200)->all();
|
||||
$productSkus = $productPhotosTable->Products->ProductSkus->find('list', limit: 200)->all();
|
||||
|
||||
$this->set(compact('productPhoto', 'products'));
|
||||
$this->set(compact('productPhoto', 'products', 'productSkus'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit method
|
||||
*
|
||||
* @param string|null $id Product Photo id.
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
* @throws RecordNotFoundException When record not found.
|
||||
*/
|
||||
public function edit($id = null)
|
||||
{
|
||||
|
@ -128,15 +132,16 @@ class ProductPhotosController extends AppController
|
|||
$this->Flash->error(__('The product photo could not be saved. Please, try again.'));
|
||||
}
|
||||
$products = $productPhotosTable->Products->find('list', limit: 200)->all();
|
||||
$this->set(compact('productPhoto', 'products'));
|
||||
$productSkus = $productPhotosTable->Products->ProductSkus->find('list', limit: 200)->all();
|
||||
$this->set(compact('productPhoto', 'products', 'productSkus'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete method
|
||||
*
|
||||
* @param string|null $id Product Photo id.
|
||||
* @return \Cake\Http\Response|null Redirects to index.
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return Response|null Redirects to index.
|
||||
* @throws RecordNotFoundException When record not found.
|
||||
*/
|
||||
public function delete($id = null)
|
||||
{
|
||||
|
|
|
@ -7,7 +7,6 @@ use Cake\Datasource\EntityInterface;
|
|||
use Cake\Datasource\ResultSetInterface;
|
||||
use Cake\ORM\Association\BelongsTo;
|
||||
use Cake\ORM\Behavior\TimestampBehavior;
|
||||
use Cake\ORM\Query\SelectQuery;
|
||||
use Cake\ORM\RulesChecker;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\Validation\Validator;
|
||||
|
|
|
@ -39,6 +39,8 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
|||
'plugin.CakeProducts.ProductCategoryVariants',
|
||||
'plugin.CakeProducts.ProductCategories',
|
||||
'plugin.CakeProducts.Products',
|
||||
'plugin.CakeProducts.ProductSkus',
|
||||
'plugin.CakeProducts.ProductPhotos',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -78,7 +80,7 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
|||
*/
|
||||
public function testIndexGet(): void
|
||||
{
|
||||
$this->loginUserByRole('admin');
|
||||
//$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ProductCategoryVariants',
|
||||
|
@ -101,7 +103,7 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
|||
public function testViewGet(): void
|
||||
{
|
||||
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
|
||||
$this->loginUserByRole('admin');
|
||||
//$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ProductCategoryVariants',
|
||||
|
@ -126,7 +128,7 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
|||
{
|
||||
$cntBefore = $this->ProductCategoryVariants->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
//$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ProductCategoryVariants',
|
||||
|
@ -154,7 +156,7 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
|||
$cntBefore = $this->ProductCategoryVariants->find()->count();
|
||||
$cntBeforeOptions = $this->ProductCategoryVariantOptions->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
//$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ProductCategoryVariants',
|
||||
|
@ -202,7 +204,7 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
|||
{
|
||||
$cntBefore = $this->ProductCategoryVariants->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
//$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ProductCategoryVariants',
|
||||
|
@ -232,7 +234,7 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
|||
*/
|
||||
public function testEditGet(): void
|
||||
{
|
||||
$this->loginUserByRole('admin');
|
||||
//$this->loginUserByRole('admin');
|
||||
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
|
||||
|
||||
$url = [
|
||||
|
@ -257,7 +259,7 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
|||
*/
|
||||
public function testEditPutLoggedInSuccess(): void
|
||||
{
|
||||
$this->loginUserByRole('admin');
|
||||
//$this->loginUserByRole('admin');
|
||||
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
|
||||
$before = $this->ProductCategoryVariants->get($id);
|
||||
$url = [
|
||||
|
@ -293,7 +295,7 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
|||
*/
|
||||
public function testEditPutLoggedInFailure(): void
|
||||
{
|
||||
$this->loginUserByRole('admin');
|
||||
//$this->loginUserByRole('admin');
|
||||
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
|
||||
$before = $this->ProductCategoryVariants->get($id);
|
||||
$url = [
|
||||
|
@ -328,7 +330,7 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
|||
{
|
||||
$cntBefore = $this->ProductCategoryVariants->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
//$this->loginUserByRole('admin');
|
||||
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
|
||||
|
||||
$url = [
|
||||
|
|
Loading…
Reference in New Issue