-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAGETWO-49595: Category page problems after pull request #367
- Loading branch information
Maksym Aposov
committed
Feb 24, 2016
1 parent
fb909a9
commit ca5d13f
Showing
6 changed files
with
169 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
app/code/Magento/Ui/Test/Unit/DataProvider/EavValidationRulesTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Ui\Test\Unit\DataProvider; | ||
|
||
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; | ||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
use Magento\Ui\DataProvider\EavValidationRules; | ||
|
||
/** | ||
* Class EavValidationRulesTest | ||
*/ | ||
class EavValidationRulesTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var ObjectManager | ||
*/ | ||
protected $objectManager; | ||
|
||
/** | ||
* @var \Magento\Ui\DataProvider\EavValidationRules | ||
*/ | ||
protected $subject; | ||
|
||
/** | ||
* @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $attributeMock; | ||
|
||
protected function setUp() | ||
{ | ||
$this->objectManager = new ObjectManager($this); | ||
$this->attributeMock = | ||
$this->getMockBuilder(AbstractAttribute::class) | ||
->setMethods(['getFrontendInput', 'getValidateRules']) | ||
->disableOriginalConstructor() | ||
->getMockForAbstractClass(); | ||
|
||
$this->subject = new EavValidationRules(); | ||
} | ||
|
||
/** | ||
* @param array $data | ||
* @param array $expected | ||
* @dataProvider buildDataProvider | ||
*/ | ||
public function testBuild($attributeInputType, $validateRules, $data, $expected) | ||
{ | ||
$this->attributeMock->expects($this->once())->method('getFrontendInput')->willReturn($attributeInputType); | ||
$this->attributeMock->expects($this->any())->method('getValidateRules')->willReturn($validateRules); | ||
$validationRules = $this->subject->build($this->attributeMock, $data); | ||
$this->assertEquals($expected, $validationRules); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function buildDataProvider() | ||
{ | ||
return [ | ||
['', '', [], []], | ||
['', null, [], []], | ||
['', false, [], []], | ||
['', [], [], []], | ||
['', '', ['required' => 1], ['required-entry' => true]], | ||
['price', '', [], ['validate-zero-or-greater' => true]], | ||
['price', '', ['required' => 1], ['validate-zero-or-greater' => true, 'required-entry' => true]], | ||
['', ['input_validation' => 'email'], [], ['validate-email' => true]], | ||
['', ['input_validation' => 'date'], [], ['validate-date' => true]], | ||
['', ['input_validation' => 'other'], [], []], | ||
['', ['max_text_length' => '254'], ['required' => 1], ['max_text_length' => 254, 'required-entry' => true]], | ||
['', ['max_text_length' => '254', 'min_text_length' => 1], [], | ||
['max_text_length' => 254, 'min_text_length' => 1]], | ||
['', ['max_text_length' => '254', 'input_validation' => 'date'], [], | ||
['max_text_length' => 254, 'validate-date' => true]], | ||
]; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Catalog\Model\Category; | ||
|
||
use Magento\Catalog\Model\Category\DataProvider; | ||
use Magento\Eav\Model\Config as EavConfig; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
|
||
class DataProviderTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var DataProvider | ||
*/ | ||
private $dataProvider; | ||
|
||
/** | ||
* @var \Magento\Eav\Model\Entity\Type | ||
*/ | ||
private $entityType; | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
$objectManager = Bootstrap::getObjectManager(); | ||
$this->dataProvider = $objectManager->create( | ||
DataProvider::class, | ||
[ | ||
'name' => 'category_form_data_source', | ||
'primaryFieldName' => 'entity_id', | ||
'requestFieldName' => 'id' | ||
] | ||
); | ||
|
||
$this->entityType = $objectManager->create(EavConfig::class)->getEntityType('catalog_category'); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testGetMetaRequiredAttributes() | ||
{ | ||
$requiredAttributes = [ | ||
'general' => ['name'], | ||
'display_settings' => ['available_sort_by', 'default_sort_by'], | ||
]; | ||
$meta = $this->dataProvider->getMeta(); | ||
$this->assertArrayHasKey('url_key', $meta['search_engine_optimization']['children']); | ||
foreach ($requiredAttributes as $scope => $attributes) { | ||
foreach ($attributes as $attribute) { | ||
$this->assertArrayHasKey($attribute, $meta[$scope]['children']); | ||
$data = $meta[$scope]['children'][$attribute]; | ||
$this->assertTrue($data['arguments']['data']['config']['validation']['required-entry']); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters