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