111 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
			
		
		
	
	
			111 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
<?php
 | 
						|
declare(strict_types=1);
 | 
						|
 | 
						|
namespace CakeProducts\Test\TestCase\Model\Table;
 | 
						|
 | 
						|
use Cake\TestSuite\TestCase;
 | 
						|
use CakeProducts\Model\Table\ProductsTable;
 | 
						|
 | 
						|
/**
 | 
						|
 * CakeProducts\Model\Table\ProductsTable Test Case
 | 
						|
 */
 | 
						|
class ProductsTableTest extends TestCase
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * Test subject
 | 
						|
     *
 | 
						|
     * @var ProductsTable
 | 
						|
     */
 | 
						|
    protected $Products;
 | 
						|
 | 
						|
    /**
 | 
						|
     * Fixtures
 | 
						|
     *
 | 
						|
     * @var array<string>
 | 
						|
     */
 | 
						|
    protected array $fixtures = [
 | 
						|
        'plugin.CakeProducts.Products',
 | 
						|
        'plugin.CakeProducts.ProductCategories',
 | 
						|
    ];
 | 
						|
 | 
						|
    /**
 | 
						|
     * setUp method
 | 
						|
     *
 | 
						|
     * @return void
 | 
						|
     */
 | 
						|
    protected function setUp(): void
 | 
						|
    {
 | 
						|
        parent::setUp();
 | 
						|
        $config = $this->getTableLocator()->exists('Products') ? [] : ['className' => ProductsTable::class];
 | 
						|
        $this->Products = $this->getTableLocator()->get('Products', $config);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * tearDown method
 | 
						|
     *
 | 
						|
     * @return void
 | 
						|
     */
 | 
						|
    protected function tearDown(): void
 | 
						|
    {
 | 
						|
        unset($this->Products);
 | 
						|
 | 
						|
        parent::tearDown();
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
    * TestInitialize method
 | 
						|
    *
 | 
						|
    * @return void
 | 
						|
    * @uses ProductsTable::initialize
 | 
						|
    */
 | 
						|
    public function testInitialize(): void
 | 
						|
    {
 | 
						|
        // verify all associations loaded
 | 
						|
        $expectedAssociations = [
 | 
						|
            'ProductCategories',
 | 
						|
            'ProductAttributes',
 | 
						|
            'ProductCategoryVariants',
 | 
						|
            'ProductSkus',
 | 
						|
        ];
 | 
						|
        $associations = $this->Products->associations();
 | 
						|
 | 
						|
        $this->assertCount(count($expectedAssociations), $associations);
 | 
						|
        foreach ($expectedAssociations as $expectedAssociation) {
 | 
						|
            $this->assertTrue($this->Products->hasAssociation($expectedAssociation));
 | 
						|
        }
 | 
						|
 | 
						|
        // verify all behaviors loaded
 | 
						|
        $expectedBehaviors = [
 | 
						|
            'Trash',
 | 
						|
        ];
 | 
						|
        $behaviors = $this->Products->behaviors();
 | 
						|
 | 
						|
        $this->assertCount(count($expectedBehaviors), $behaviors);
 | 
						|
        foreach ($expectedBehaviors as $expectedBehavior) {
 | 
						|
            $this->assertTrue($this->Products->hasBehavior($expectedBehavior));
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
    * Test validationDefault method
 | 
						|
    *
 | 
						|
    * @return void
 | 
						|
    * @uses ProductsTable::validationDefault
 | 
						|
    */
 | 
						|
    public function testValidationDefault(): void
 | 
						|
    {
 | 
						|
        $this->markTestIncomplete('Not implemented yet.');
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
    * Test buildRules method
 | 
						|
    *
 | 
						|
    * @return void
 | 
						|
    * @uses ProductsTable::buildRules
 | 
						|
    */
 | 
						|
    public function testBuildRules(): void
 | 
						|
    {
 | 
						|
        $this->markTestIncomplete('Not implemented yet.');
 | 
						|
    }
 | 
						|
}
 |