-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix integer indexing for very long values.
- Loading branch information
Aurélien FOUCRET
committed
Jan 4, 2018
1 parent
265d9ac
commit 6bea9d5
Showing
4 changed files
with
80 additions
and
3 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
71 changes: 71 additions & 0 deletions
71
src/module-elasticsuite-catalog/Test/Unit/Helper/AbstractAttributeTest.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,71 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* Do not edit or add to this file if you wish to upgrade Smile Elastic Suite to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCatalog | ||
* @author Aurelien FOUCRET <[email protected]> | ||
* @copyright 2016 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
|
||
namespace Smile\ElasticsuiteCatalog\Test\Unit\Helper; | ||
|
||
use Smile\ElasticsuiteCore\Api\Index\Mapping\FieldInterface; | ||
use Smile\ElasticsuiteCatalog\Helper\AbstractAttribute; | ||
|
||
/** | ||
* Attribute helper unit test. | ||
* | ||
* @category Smile_Elasticsuite | ||
* @package Smile\ElasticsuiteCatalog | ||
* @author Aurelien FOUCRET <[email protected]> | ||
*/ | ||
class AbstractAttributeTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* Test automatic attribute ES field type detection. | ||
* | ||
* @dataProvider attributeTypeProvider | ||
* | ||
* @param string $backendType Attribute backend type. | ||
* @param bool $usesSource Does attribute uses source. | ||
* @param string $sourceModel Attribute source model | ||
* @param string $frontendClass Attribute frontend class. | ||
* @param string $expectedType Expected ES field type. | ||
* | ||
* @return void | ||
*/ | ||
public function testFieldTypes($backendType, $usesSource, $sourceModel, $frontendClass, $expectedType) | ||
{ | ||
$attributeMock = $this->createMock(\Magento\Catalog\Model\Entity\Attribute::class); | ||
$attributeMock->expects($this->any())->method('getBackendType')->will($this->returnValue($backendType)); | ||
$attributeMock->method('usesSource')->will($this->returnValue($usesSource)); | ||
$attributeMock->method('getSourceModel')->will($this->returnValue($sourceModel)); | ||
$attributeMock->method('getFrontendClass')->will($this->returnValue($frontendClass)); | ||
|
||
$helperMock = $this->getMockForAbstractClass(AbstractAttribute::class, [], '', false); | ||
$this->assertEquals($expectedType, $helperMock->getFieldType($attributeMock)); | ||
} | ||
|
||
/** | ||
* List of tested combination for the getFieldType method. | ||
* | ||
* @return array | ||
*/ | ||
public function attributeTypeProvider() | ||
{ | ||
return [ | ||
['int', true, 'Magento\Eav\Model\Entity\Attribute\Source\Boolean', null, FieldInterface::FIELD_TYPE_BOOLEAN], | ||
['int', false, null, null, FieldInterface::FIELD_TYPE_INTEGER], | ||
['varchar', false, null, 'validate-digits', FieldInterface::FIELD_TYPE_LONG], | ||
['decimal', false, null, null, FieldInterface::FIELD_TYPE_DOUBLE], | ||
['varchar', false, null, 'validate-number', FieldInterface::FIELD_TYPE_DOUBLE], | ||
['datetime', false, null, null, FieldInterface::FIELD_TYPE_DATE], | ||
['varchar', true, null, null, FieldInterface::FIELD_TYPE_INTEGER], | ||
['varchar', false, null, null, FieldInterface::FIELD_TYPE_STRING], | ||
]; | ||
} | ||
} |
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