diff --git a/.travis.yml b/.travis.yml index 210ebc900..dc9048641 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,59 +1,53 @@ sudo: required -dist: trusty +dist: xenial services: - elasticsearch - -addons: - apt: - packages: - - mysql-server-5.6 - - mysql-client-core-5.6 - - mysql-client-5.6 - - postfix - - oracle-java9-set-default + - mysql language: php jobs: include: # Elasticsearch 6 - - php: 7.2 - env: - - ES_VERSION=6.8.8 MAGENTO_VERSION=2.3.5-p1 MAGENTO_EDITION=community - - if: type != pull_request - php: 7.2 - env: - - ES_VERSION=6.8.8 MAGENTO_VERSION=2.3.5-p1 MAGENTO_EDITION=enterprise - php: 7.3 env: - - ES_VERSION=6.8.8 MAGENTO_VERSION=2.3.5-p1 MAGENTO_EDITION=community + - ES_VERSION=6.8.8 MAGENTO_VERSION=2.4.0 MAGENTO_EDITION=community - if: type != pull_request php: 7.3 env: - - ES_VERSION=6.8.8 MAGENTO_VERSION=2.3.5-p1 MAGENTO_EDITION=enterprise -# Elasticsearch 7 - - php: 7.2 + - ES_VERSION=6.8.8 MAGENTO_VERSION=2.4.0 MAGENTO_EDITION=enterprise + - php: 7.4 env: - - ES_VERSION=7.6.2-amd64 MAGENTO_VERSION=2.3.5-p1 MAGENTO_EDITION=community + - ES_VERSION=6.8.8 MAGENTO_VERSION=2.4.0 MAGENTO_EDITION=community - if: type != pull_request - php: 7.2 + php: 7.4 env: - - ES_VERSION=7.6.2-amd64 MAGENTO_VERSION=2.3.5-p1 MAGENTO_EDITION=enterprise + - ES_VERSION=6.8.8 MAGENTO_VERSION=2.4.0 MAGENTO_EDITION=enterprise +# Elasticsearch 7 - php: 7.3 env: - - ES_VERSION=7.6.2-amd64 MAGENTO_VERSION=2.3.5-p1 MAGENTO_EDITION=community + - ES_VERSION=7.6.2-amd64 MAGENTO_VERSION=2.4.0 MAGENTO_EDITION=community - if: type != pull_request php: 7.3 env: - - ES_VERSION=7.6.2-amd64 MAGENTO_VERSION=2.3.5-p1 MAGENTO_EDITION=enterprise + - ES_VERSION=7.6.2-amd64 MAGENTO_VERSION=2.4.0 MAGENTO_EDITION=enterprise + - php: 7.4 + env: + - ES_VERSION=7.6.2-amd64 MAGENTO_VERSION=2.4.0 MAGENTO_EDITION=community + - if: type != pull_request + php: 7.4 + env: + - ES_VERSION=7.6.2-amd64 MAGENTO_VERSION=2.4.0 MAGENTO_EDITION=enterprise before_install: - sudo service elasticsearch stop - export ES_HOME=/usr/share/elasticsearch - curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$ES_VERSION.deb - sudo dpkg -i --force-confnew elasticsearch-$ES_VERSION.deb + - yes | sudo $ES_HOME/bin/elasticsearch-plugin remove analysis-icu || return 0 - yes | sudo $ES_HOME/bin/elasticsearch-plugin install analysis-icu + - yes | sudo $ES_HOME/bin/elasticsearch-plugin remove analysis-phonetic || return 0 - yes | sudo $ES_HOME/bin/elasticsearch-plugin install analysis-phonetic - sudo chgrp elasticsearch /etc/default/elasticsearch -R - sudo service elasticsearch start diff --git a/Resources/tests/unit/phpunit.xml b/Resources/tests/unit/phpunit.xml index be1359007..914f2e6a8 100644 --- a/Resources/tests/unit/phpunit.xml +++ b/Resources/tests/unit/phpunit.xml @@ -14,7 +14,7 @@ */ --> - + ../../../src/* ../../../src/*/Test diff --git a/Resources/travis/prepare_php.sh b/Resources/travis/prepare_php.sh index 9a91c0faf..2c8680db3 100644 --- a/Resources/travis/prepare_php.sh +++ b/Resources/travis/prepare_php.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit code $?' ERR -echo '==> Disabling xdebug, adjusting memory limit to -1.' -phpenv config-rm xdebug.ini +echo '==> Disabling xdebug if needed, adjusting memory limit to -1.' +phpenv config-rm xdebug.ini || return 0 echo 'memory_limit = -1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini phpenv rehash; diff --git a/composer.json b/composer.json index 7413c6c57..ff9edf54d 100644 --- a/composer.json +++ b/composer.json @@ -62,7 +62,7 @@ "smile/module-elasticsuite-virtual-category": "self.version" }, "require-dev": { - "smile/magento2-smilelab-quality-suite": "~2.1.0" + "smile/magento2-smilelab-quality-suite": "~2.2.0" }, "autoload": { "files": [ diff --git a/src/module-elasticsuite-catalog-optimizer/Model/Optimizer/Preview.php b/src/module-elasticsuite-catalog-optimizer/Model/Optimizer/Preview.php index ddc547ae8..fbe39520d 100644 --- a/src/module-elasticsuite-catalog-optimizer/Model/Optimizer/Preview.php +++ b/src/module-elasticsuite-catalog-optimizer/Model/Optimizer/Preview.php @@ -175,13 +175,13 @@ private function canApply() : bool $canApply = in_array($this->containerConfiguration->getName(), $this->optimizer->getSearchContainer(), true); if ($canApply && $this->containerConfiguration->getName() === 'quick_search_container') { $config = $this->optimizer->getQuickSearchContainer(); - if ((int) $config['apply_to'] === 1 && !empty($config['query_ids'])) { + if ((int) ($config['apply_to'] ?? 0) === 1 && !empty($config['query_ids'])) { $queries = array_column($config['query_ids'], 'query_text'); $canApply = in_array($this->queryText, $queries, true); } } elseif ($canApply && $this->containerConfiguration->getName() === 'catalog_view_container') { $config = $this->optimizer->getCatalogViewContainer(); - if ((int) $config['apply_to'] === 1 && !empty($config['category_ids'])) { + if ((int) ($config['apply_to'] ?? 0) === 1 && !empty($config['category_ids'])) { $categoryIds = array_filter($config['category_ids']); $canApply = in_array($this->category->getId(), $categoryIds, true); } diff --git a/src/module-elasticsuite-catalog-optimizer/Test/Unit/Model/Optimizer/PreviewTest.php b/src/module-elasticsuite-catalog-optimizer/Test/Unit/Model/Optimizer/PreviewTest.php index 9109f9efe..c3c7d2e93 100644 --- a/src/module-elasticsuite-catalog-optimizer/Test/Unit/Model/Optimizer/PreviewTest.php +++ b/src/module-elasticsuite-catalog-optimizer/Test/Unit/Model/Optimizer/PreviewTest.php @@ -15,7 +15,6 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject; use ReflectionClass; use Smile\ElasticsuiteCatalogOptimizer\Model\Optimizer\ApplierListFactory; use Smile\ElasticsuiteCatalogOptimizer\Model\Optimizer\Preview; @@ -79,7 +78,7 @@ class PreviewTest extends TestCase /** * {@inheritDoc} */ - protected function setUp() + protected function setUp(): void { $this->optimizer = $this->getOptimizerMock(); $this->previewItemFactory = $this->getPreviewItemFactoryMock(); @@ -435,9 +434,9 @@ private function getResultsBuilderMock() : MockObject /** * Generate container config mock. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ - private function getContainerConfigMock(): PHPUnit_Framework_MockObject_MockObject + private function getContainerConfigMock(): \PHPUnit\Framework\MockObject\MockObject { return $this->getMockBuilder(ContainerConfigurationInterface::class) ->getMock(); @@ -446,9 +445,9 @@ private function getContainerConfigMock(): PHPUnit_Framework_MockObject_MockObje /** * Generate category mock. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ - private function getCategoryMock(): PHPUnit_Framework_MockObject_MockObject + private function getCategoryMock(): \PHPUnit\Framework\MockObject\MockObject { return $this ->getMockBuilder(CategoryInterface::class) @@ -459,9 +458,9 @@ private function getCategoryMock(): PHPUnit_Framework_MockObject_MockObject /** * Generate optimizer mock. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ - private function getOptimizerMock(): PHPUnit_Framework_MockObject_MockObject + private function getOptimizerMock(): \PHPUnit\Framework\MockObject\MockObject { return $this ->getMockBuilder(Optimizer::class) @@ -473,9 +472,9 @@ private function getOptimizerMock(): PHPUnit_Framework_MockObject_MockObject /** * Generate item factory mock. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ - private function getPreviewItemFactoryMock(): PHPUnit_Framework_MockObject_MockObject + private function getPreviewItemFactoryMock(): \PHPUnit\Framework\MockObject\MockObject { return $this ->getMockBuilder('\Smile\ElasticsuiteCatalogOptimizer\Model\Optimizer\Preview\ItemFactory') @@ -486,9 +485,9 @@ private function getPreviewItemFactoryMock(): PHPUnit_Framework_MockObject_MockO /** * Generate applier list factory mock. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ - private function getApplierListFactoryMock(): PHPUnit_Framework_MockObject_MockObject + private function getApplierListFactoryMock(): \PHPUnit\Framework\MockObject\MockObject { return $this ->getMockBuilder('\Smile\ElasticsuiteCatalogOptimizer\Model\Optimizer\ApplierListFactory') @@ -499,9 +498,9 @@ private function getApplierListFactoryMock(): PHPUnit_Framework_MockObject_MockO /** * Generate provider factory mock. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ - private function getProviderFactoryMock(): PHPUnit_Framework_MockObject_MockObject + private function getProviderFactoryMock(): \PHPUnit\Framework\MockObject\MockObject { return $this ->getMockBuilder(ProviderFactory::class) diff --git a/src/module-elasticsuite-core/Test/Unit/Index/Analysis/Config/ConverterTest.php b/src/module-elasticsuite-core/Test/Unit/Index/Analysis/Config/ConverterTest.php index a2420f97a..7e83eaa2e 100644 --- a/src/module-elasticsuite-core/Test/Unit/Index/Analysis/Config/ConverterTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Index/Analysis/Config/ConverterTest.php @@ -34,7 +34,7 @@ class ConverterTest extends \PHPUnit\Framework\TestCase * * {@inheritDoc} */ - protected function setUp() + protected function setUp(): void { $xml = new \DOMDocument(); $xml->load(__DIR__ . '/elasticsuite_analysis.xml'); diff --git a/src/module-elasticsuite-core/Test/Unit/Index/Bulk/BulkRequestTest.php b/src/module-elasticsuite-core/Test/Unit/Index/Bulk/BulkRequestTest.php index a7c3ce3df..3cc8a308f 100644 --- a/src/module-elasticsuite-core/Test/Unit/Index/Bulk/BulkRequestTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Index/Bulk/BulkRequestTest.php @@ -36,7 +36,7 @@ class BulkRequestTest extends \PHPUnit\Framework\TestCase * * {@inheritDoc} */ - protected function setUp() + protected function setUp(): void { $this->index = $this->getMockBuilder(IndexInterface::class)->getMock(); $this->index->method('getName')->will($this->returnValue('indexName')); diff --git a/src/module-elasticsuite-core/Test/Unit/Index/Bulk/BulkResponseTest.php b/src/module-elasticsuite-core/Test/Unit/Index/Bulk/BulkResponseTest.php index b07c9775b..14039da5d 100644 --- a/src/module-elasticsuite-core/Test/Unit/Index/Bulk/BulkResponseTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Index/Bulk/BulkResponseTest.php @@ -34,7 +34,7 @@ class BulkResponseTest extends \PHPUnit\Framework\TestCase * * {@inheritDoc} */ - protected function setUp() + protected function setUp(): void { $error1 = ['type' => 'reason1', 'reason' => 'Reason 1']; $error2 = ['type' => 'reason2', 'reason' => 'Reason 2']; diff --git a/src/module-elasticsuite-core/Test/Unit/Index/IndexOperationTest.php b/src/module-elasticsuite-core/Test/Unit/Index/IndexOperationTest.php index 554366a99..ed401e519 100644 --- a/src/module-elasticsuite-core/Test/Unit/Index/IndexOperationTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Index/IndexOperationTest.php @@ -32,7 +32,7 @@ class IndexOperationTest extends \PHPUnit\Framework\TestCase private $indexOperation; /** - * @var \Elasticsearch\Client|\PHPUnit_Framework_MockObject_MockObject + * @var \Elasticsearch\Client|\\PHPUnit\Framework\MockObject\MockObject */ private $clientMock; @@ -46,7 +46,7 @@ class IndexOperationTest extends \PHPUnit\Framework\TestCase * * {@inheritDoc} */ - protected function setUp() + protected function setUp(): void { $this->initClientMock(); @@ -93,13 +93,12 @@ public function testGetIndexByName() /** * Test accessing a not existing index throws an exception. * - * @expectedException \LogicException - * @expectedExceptionMessage invalid_index_identifier index does not exist yet. Make sure everything is reindexed. - * * @return void */ public function testGetIndexInvalidByName() { + $this->expectExceptionMessage("invalid_index_identifier index does not exist yet. Make sure everything is reindexed."); + $this->expectException(\LogicException::class); $index = $this->indexOperation->getIndexByName('invalid_index_identifier', 'store_code'); $this->assertInstanceOf(\Smile\ElasticsuiteCore\Api\Index\IndexInterface::class, $index); } @@ -178,13 +177,12 @@ public function testExecuteBulkWithErrors() /** * Test empty bulk execution throws an exception. * - * @expectedException \LogicException - * @expectedExceptionMessage Can not execute empty bulk. - * * @return void */ public function testExecuteEmptyBulk() { + $this->expectExceptionMessage("Can not execute empty bulk."); + $this->expectException(\LogicException::class); $bulk = new \Smile\ElasticsuiteCore\Index\Bulk\BulkRequest(); $this->indexOperation->executeBulk($bulk); } @@ -201,7 +199,7 @@ public function testGetBatchIndexingSize() /** * Object manager mocking. - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getObjectManagerMock() { @@ -234,7 +232,7 @@ private function getObjectManagerMock() /** * Client factory mocking. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function initClientMock() { @@ -251,7 +249,7 @@ private function initClientMock() /** * Index settings mocking. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getIndexSettingsMock() { @@ -270,7 +268,7 @@ private function getIndexSettingsMock() /** * Logger mocking. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getLoggerMock() { diff --git a/src/module-elasticsuite-core/Test/Unit/Index/IndexSettingsTest.php b/src/module-elasticsuite-core/Test/Unit/Index/IndexSettingsTest.php index 04f423fcc..06dded5ff 100644 --- a/src/module-elasticsuite-core/Test/Unit/Index/IndexSettingsTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Index/IndexSettingsTest.php @@ -78,13 +78,12 @@ public function testGetIndexConfig() /** * Test an exception is raised when accessing an index that does not exists in the configuration. * - * @expectedException \LogicException - * @expectedExceptionMessage No indices found with identifier invalidIndex - * * @return void */ public function testGetInvalidIndexConfig() { + $this->expectExceptionMessage("No indices found with identifier invalidIndex"); + $this->expectException(\LogicException::class); $this->indexSettings->getIndexConfig('invalidIndex'); } @@ -116,7 +115,7 @@ public function testIndexingSettings() /** * {@inheritDoc} */ - protected function setUp() + protected function setUp(): void { $indexSettingHelper = $this->getIndexSettingsMock(); $indicesConfig = $this->getIndicesConfigMock(); @@ -128,7 +127,7 @@ protected function setUp() /** * Generate the index settings helper mock. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getIndexSettingsMock() { @@ -158,7 +157,7 @@ function ($indexIdentifier, $store) { /** * Generate the indices config mock. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getIndicesConfigMock() { @@ -171,7 +170,7 @@ private function getIndicesConfigMock() /** * Generate the analysis config mock. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getAnalysisConfigMock() { diff --git a/src/module-elasticsuite-core/Test/Unit/Index/IndexTest.php b/src/module-elasticsuite-core/Test/Unit/Index/IndexTest.php index 60def9f2e..4a55f5244 100644 --- a/src/module-elasticsuite-core/Test/Unit/Index/IndexTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Index/IndexTest.php @@ -37,7 +37,7 @@ class IndexTest extends \PHPUnit\Framework\TestCase * * {@inheritDoc} */ - protected function setUp() + protected function setUp(): void { $fieldMock = $this->getMockBuilder(FieldInterface::class)->getMock(); diff --git a/src/module-elasticsuite-core/Test/Unit/Index/Indices/Config/ConverterTest.php b/src/module-elasticsuite-core/Test/Unit/Index/Indices/Config/ConverterTest.php index 904a5f338..1fdc2ab98 100644 --- a/src/module-elasticsuite-core/Test/Unit/Index/Indices/Config/ConverterTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Index/Indices/Config/ConverterTest.php @@ -32,7 +32,7 @@ class ConverterTest extends \PHPUnit\Framework\TestCase /** * {@inheritDoc} */ - protected function setUp() + protected function setUp(): void { $xml = new \DOMDocument(); $xml->load(__DIR__ . '/elasticsuite_indices.xml'); diff --git a/src/module-elasticsuite-core/Test/Unit/Index/Mapping/FieldTest.php b/src/module-elasticsuite-core/Test/Unit/Index/Mapping/FieldTest.php index a44f9506a..58d6217e5 100644 --- a/src/module-elasticsuite-core/Test/Unit/Index/Mapping/FieldTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Index/Mapping/FieldTest.php @@ -76,13 +76,12 @@ public function testNestedField() /** * Test invalid nested field configuration. * - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Invalid nested path or field name - * * @return void */ public function testInvalidNestedField() { + $this->expectExceptionMessage("Invalid nested path or field name"); + $this->expectException(\InvalidArgumentException::class); new Field('parent.child', FieldInterface::FIELD_TYPE_TEXT, 'invalidparent'); } diff --git a/src/module-elasticsuite-core/Test/Unit/Index/MappingTest.php b/src/module-elasticsuite-core/Test/Unit/Index/MappingTest.php index b4cc2de1b..7da683739 100644 --- a/src/module-elasticsuite-core/Test/Unit/Index/MappingTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Index/MappingTest.php @@ -40,7 +40,7 @@ class MappingTest extends \PHPUnit\Framework\TestCase * * {@inheritDoc} */ - protected function setUp() + protected function setUp(): void { // Static fields. $fields = [ @@ -149,13 +149,12 @@ public function testObjectField() /** * Test an exception is raised when trying to access a missing field. * - * @expectedException \LogicException - * @expectedExceptionMessage Field invalidField does not exists in mapping - * * @return void */ public function testMissingFieldAccess() { + $this->expectExceptionMessage("Field invalidField does not exists in mapping"); + $this->expectException(\LogicException::class); $this->mapping->getField('invalidField'); } @@ -174,13 +173,12 @@ public function testMappingGeneration() /** * Test an exception is raised when using an invalid id field as id. * - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Invalid id field missingField : field is not declared. - * * @return void */ public function testInvalidIdField() { + $this->expectExceptionMessage("Invalid id field missingField : field is not declared."); + $this->expectException(\InvalidArgumentException::class); new Mapping('missingField'); } @@ -229,26 +227,24 @@ public function testGetWeightedSearchProperties() /** * Test an exception is thrown when using an invalid default field. * - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Unable to find field invalidDefaultField. - * * @return void */ public function testInvalidDefaultField() { + $this->expectExceptionMessage("Unable to find field invalidDefaultField."); + $this->expectException(\InvalidArgumentException::class); $this->getSearchWeightedMapping()->getWeightedSearchProperties(null, 'invalidDefaultField'); } /** * Test an exception is thrown when using an invalid analyzer. * - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Unable to find analyzer invalidAnalyzer for field search. - * * @return void */ public function testInvalidDefaultFieldAnalyzer() { + $this->expectExceptionMessage("Unable to find analyzer invalidAnalyzer for field search."); + $this->expectException(\InvalidArgumentException::class); $this->getSearchWeightedMapping()->getWeightedSearchProperties('invalidAnalyzer', Mapping::DEFAULT_SEARCH_FIELD); } diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/AdapterTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/AdapterTest.php index 6a96a02bb..67f256902 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/AdapterTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/AdapterTest.php @@ -79,7 +79,7 @@ public function testError() /** * {@inheritDoc} */ - protected function setUp() + protected function setUp(): void { $queryResponseFactory = $this->getQueryResponseFactoryMock(); $requestMapper = $this->getRequestMapperMock(); @@ -92,7 +92,7 @@ protected function setUp() /** * Init a mocked search request mapper. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getRequestMapperMock() { @@ -106,7 +106,7 @@ private function getRequestMapperMock() /** * Init a mocked search response factory. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getQueryResponseFactoryMock() { @@ -123,7 +123,7 @@ private function getQueryResponseFactoryMock() /** * Init a mocked ES client factory. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getClientMock() { diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Aggregation/Builder/HistorgramTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Aggregation/Builder/HistorgramTest.php index dd55e1cbc..ce7b0972f 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Aggregation/Builder/HistorgramTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Aggregation/Builder/HistorgramTest.php @@ -47,13 +47,12 @@ public function testHistogramAggregationBuild() /** * Test an exception is thrown when using the term aggs builder with another bucket type. * - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Query builder : invalid aggregation type invalidType. - * * @return void */ public function testInvalidBucketAggregationBuild() { + $this->expectExceptionMessage("Query builder : invalid aggregation type invalidType."); + $this->expectException(\InvalidArgumentException::class); $termBucket = $this->getMockBuilder(BucketInterface::class)->getMock(); $termBucket->method('getType')->will($this->returnValue('invalidType')); diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Aggregation/Builder/QueryGroupTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Aggregation/Builder/QueryGroupTest.php index cac2105fc..ee4c41d8e 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Aggregation/Builder/QueryGroupTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Aggregation/Builder/QueryGroupTest.php @@ -52,13 +52,12 @@ public function testBasicTermAggregationBuild() /** * Test an exception is thrown when using the term aggs builder with another bucket type. * - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Query builder : invalid aggregation type invalidType. - * * @return void */ public function testInvalidBucketAggregationBuild() { + $this->expectExceptionMessage("Query builder : invalid aggregation type invalidType."); + $this->expectException(\InvalidArgumentException::class); $termBucket = $this->getMockBuilder(BucketInterface::class)->getMock(); $termBucket->method('getType')->will($this->returnValue('invalidType')); diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Aggregation/Builder/TermTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Aggregation/Builder/TermTest.php index f9c02088c..2642943ee 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Aggregation/Builder/TermTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Aggregation/Builder/TermTest.php @@ -85,13 +85,12 @@ public function testRelevanceSortOrderTermAggregationBuild() /** * Test an exception is thrown when using the term aggs builder with another bucket type. * - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Query builder : invalid aggregation type invalidType. - * * @return void */ public function testInvalidBucketAggregationBuild() { + $this->expectExceptionMessage("Query builder : invalid aggregation type invalidType."); + $this->expectException(\InvalidArgumentException::class); $termBucket = $this->getMockBuilder(BucketInterface::class)->getMock(); $termBucket->method('getType')->will($this->returnValue('invalidType')); diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Aggregation/BuilderTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Aggregation/BuilderTest.php index 70699c7fa..c7ab7641a 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Aggregation/BuilderTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Aggregation/BuilderTest.php @@ -118,13 +118,12 @@ public function testBuildFilteredAggregation() /** * Test an exception is thrown when trying to build a bucket which is not handled by the builder. * - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage No builder found for aggregation type invalidBucketType. - * * @return void */ public function testBuildInvalidAggregation() { + $this->expectExceptionMessage("No builder found for aggregation type invalidBucketType."); + $this->expectException(\InvalidArgumentException::class); $buckets = [$this->createNestedBucket('aggregation', 'invalidBucketType')]; $this->getAggregationBuilder()->buildAggregations($buckets); } @@ -181,7 +180,7 @@ private function getAggregationBuilder() * @param array $metrics Bucket metrics. * @param array $pipelines Bucket pipeline aggregations. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function createBucket($name, $type, $metrics = [], $pipelines = []) { @@ -201,7 +200,7 @@ private function createBucket($name, $type, $metrics = [], $pipelines = []) * @param string $name Bucket name. * @param string $type Bucket type. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function createNestedBucket($name, $type) { @@ -218,7 +217,7 @@ private function createNestedBucket($name, $type) * @param string $name Bucket name. * @param string $type Bucket type. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function createFilteredNestedBucket($name, $type) { @@ -237,7 +236,7 @@ private function createFilteredNestedBucket($name, $type) * @param string $name Bucket name. * @param string $type Bucket type. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function createFilteredBucket($name, $type) { @@ -256,7 +255,7 @@ private function createFilteredBucket($name, $type) * @param string $pipelineName Pipeline name. * @param string $pipelineType Pipeline type. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function createPipelinedBucket($name, $type, $pipelineName, $pipelineType) { @@ -272,7 +271,7 @@ private function createPipelinedBucket($name, $type, $pipelineName, $pipelineTyp * @param string $name Pipeline name. * @param string $type Pipeline type. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function createPipeline($name, $type) { diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Query/Builder/AbstractComplexQueryBuilderTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Query/Builder/AbstractComplexQueryBuilderTest.php index af6767ec0..f84c4fa2d 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Query/Builder/AbstractComplexQueryBuilderTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Query/Builder/AbstractComplexQueryBuilderTest.php @@ -25,7 +25,7 @@ abstract class AbstractComplexQueryBuilderTest extends AbstractSimpleQueryBuilde /** * Return a mocked parent query builder used to build subqueries. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ protected function getParentQueryBuilder() { @@ -47,7 +47,7 @@ protected function getParentQueryBuilder() * * @param string $queryName Query name. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ protected function getSubQueryMock($queryName) { diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Query/Builder/AbstractSimpleQueryBuilderTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Query/Builder/AbstractSimpleQueryBuilderTest.php index 45186578e..46348fdaf 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Query/Builder/AbstractSimpleQueryBuilderTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Query/Builder/AbstractSimpleQueryBuilderTest.php @@ -25,13 +25,12 @@ abstract class AbstractSimpleQueryBuilderTest extends \PHPUnit\Framework\TestCas /** * Test using the query builder with an invalid query type throws an exception. * - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Query builder : invalid query type invalid_type - * * @return void */ public function testInvalidQuery() { + $this->expectExceptionMessage("Query builder : invalid query type invalid_type"); + $this->expectException(\InvalidArgumentException::class); $builder = $this->getQueryBuilder(); $query = $this->getMockBuilder(\Smile\ElasticsuiteCore\Search\Request\QueryInterface::class)->getMock(); diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Query/BuilderTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Query/BuilderTest.php index 7e2b6df0d..871785e69 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Query/BuilderTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/Query/BuilderTest.php @@ -42,13 +42,12 @@ public function testBuildValidQuery() /** * Test the query builder throws an exception when using an invalid query type. * - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Unknow query builder for invalidQueryType. - * * @return void */ public function testBuildInvalidQuery() { + $this->expectExceptionMessage("Unknow query builder for invalidQueryType."); + $this->expectException(\InvalidArgumentException::class); $query = $this->getMockBuilder(QueryInterface::class)->getMock(); $query->method('getType')->will($this->returnValue('invalidQueryType')); diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Request/Aggregation/AggregationBuilderTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Request/Aggregation/AggregationBuilderTest.php index b0233a392..30e0d8d92 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Request/Aggregation/AggregationBuilderTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Request/Aggregation/AggregationBuilderTest.php @@ -197,7 +197,7 @@ private function getQueryBuilder() /** * Aggregation factory used during tests. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getAggregationFactory() { @@ -212,7 +212,7 @@ private function getAggregationFactory() /** * Container configuration used during tests. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getContainerConfiguration() { @@ -247,7 +247,7 @@ private function getMapping() /** * Metrics factory used during tests. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getMetricFactory() { diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Request/Aggregation/AggregationFactoryTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Request/Aggregation/AggregationFactoryTest.php index 1d00536f6..8efd1130c 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Request/Aggregation/AggregationFactoryTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Request/Aggregation/AggregationFactoryTest.php @@ -39,13 +39,12 @@ public function testAggregationCreate() /** * Test submitting an invalid aggregation type throws an exception. * - * @expectedException \LogicException - * @expectedExceptionMessage No factory found for aggregation of type invalidAggregationType - * * @return void */ public function testInvalidAggregationCreate() { + $this->expectExceptionMessage("No factory found for aggregation of type invalidAggregationType"); + $this->expectException(\LogicException::class); $this->getAggregationFactory()->create('invalidAggregationType', []); } diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Request/Aggregation/PipelineFactoryTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Request/Aggregation/PipelineFactoryTest.php index 0efaee1f6..de81edee3 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Request/Aggregation/PipelineFactoryTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Request/Aggregation/PipelineFactoryTest.php @@ -39,13 +39,12 @@ public function testPipelineCreate() /** * Test trying to create an invalid pipeline aggregation type throws an exception. * - * @expectedException \LogicException - * @expectedExceptionMessage No factory found for pipeline aggregation of type invalidPipelineType - * * @return void */ public function testInvalidPipelineCreate() { + $this->expectExceptionMessage("No factory found for pipeline aggregation of type invalidPipelineType"); + $this->expectException(\LogicException::class); $this->getPipelineFactory()->create('invalidPipelineType', []); } diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/BuilderTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/BuilderTest.php index 223d7ac3b..36c4ea011 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/BuilderTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/BuilderTest.php @@ -63,7 +63,7 @@ public function testCreateQuery() /** * Mocks the search context. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getSearchContext() { @@ -73,7 +73,7 @@ private function getSearchContext() /** * Mocks the container configration. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getContainerConfiguration() { @@ -89,7 +89,7 @@ private function getContainerConfiguration() * * @SuppressWarnings(PHPMD.UnusedLocalVariable) * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getQueryFactory() { @@ -109,7 +109,7 @@ private function getQueryFactory() /** * Mocks the fulltext query builder. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getFulltextQueryBuilder() { @@ -119,7 +119,7 @@ private function getFulltextQueryBuilder() /** * Mocks the filters query builder. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getFilterQueryBuilder() { @@ -132,7 +132,7 @@ private function getFilterQueryBuilder() * @param string $class Mocked class name. * @param string $name Mock returned query type. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getQueryBuilder($class, $name) { diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/Filter/QueryBuilderTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/Filter/QueryBuilderTest.php index 963f30f20..54a9a87f1 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/Filter/QueryBuilderTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/Filter/QueryBuilderTest.php @@ -149,13 +149,12 @@ public function testNestedFieldFilter() /** * Test using an not supported exception throws an exception. * - * @expectedException \LogicException - * @expectedExceptionMessage Condition regexp is not supported. - * * @return void */ public function testUnsupportedCondition() { + $this->expectExceptionMessage("Condition regexp is not supported."); + $this->expectException(\LogicException::class); $this->buildQuery(['simpleTextField' => ['regexp' => 'filterValue']]); } @@ -203,7 +202,7 @@ private function getQueryFactory($queryTypes) * * @param \Smile\ElasticsuiteCore\Api\Index\Mapping\FieldInterface[] $fields Mapping fields. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getContainerConfigMock($fields) { diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/Fulltext/QueryBuilderTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/Fulltext/QueryBuilderTest.php index 5cfe103ce..65aff74c5 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/Fulltext/QueryBuilderTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/Fulltext/QueryBuilderTest.php @@ -183,7 +183,7 @@ private function getQueryFactory($queryTypes) * * @param \Smile\ElasticsuiteCore\Api\Index\Mapping\FieldInterface[] $fields Mapping fields. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getContainerConfigMock($fields) { @@ -202,7 +202,7 @@ private function getContainerConfigMock($fields) /** * Mock the relevace configuration object used by the query builder. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function getRelevanceConfig() { diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/QueryFactoryTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/QueryFactoryTest.php index 0672015e2..1d91e7d43 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/QueryFactoryTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/QueryFactoryTest.php @@ -39,13 +39,12 @@ public function testQueryCreate() /** * Test submitting an invalid query type throws an exception. * - * @expectedException \LogicException - * @expectedExceptionMessage No factory found for query of type invalidQueryType - * * @return void */ public function testInvalidQueryCreate() { + $this->expectExceptionMessage("No factory found for query of type invalidQueryType"); + $this->expectException(\LogicException::class); $this->getQueryFactory()->create('invalidQueryType', []); }