Skip to content

Commit

Permalink
Update Travis test scenario for Magento 2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
romainruaud committed Jul 31, 2020
1 parent 6f5b5e0 commit 700c580
Show file tree
Hide file tree
Showing 30 changed files with 116 additions and 141 deletions.
46 changes: 20 additions & 26 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions Resources/tests/unit/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
-->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.3/phpunit.xsd"
colors="true"
bootstrap="./framework/bootstrap.php"
backupGlobals="false"
Expand All @@ -30,7 +30,7 @@
</php>

<filter>
<whitelist addUncoveredFilesFromWhiteList="true">
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">../../../src/*</directory>
<exclude>
<directory>../../../src/*/Test</directory>
Expand Down
4 changes: 2 additions & 2 deletions Resources/travis/prepare_php.sh
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -79,7 +78,7 @@ class PreviewTest extends TestCase
/**
* {@inheritDoc}
*/
protected function setUp()
protected function setUp(): void
{
$this->optimizer = $this->getOptimizerMock();
$this->previewItemFactory = $this->getPreviewItemFactoryMock();
Expand Down Expand Up @@ -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();
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
22 changes: 10 additions & 12 deletions src/module-elasticsuite-core/Test/Unit/Index/IndexOperationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -46,7 +46,7 @@ class IndexOperationTest extends \PHPUnit\Framework\TestCase
*
* {@inheritDoc}
*/
protected function setUp()
protected function setUp(): void
{
$this->initClientMock();

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -201,7 +199,7 @@ public function testGetBatchIndexingSize()

/**
* Object manager mocking.
* @return PHPUnit_Framework_MockObject_MockObject
* @return \PHPUnit\Framework\MockObject\MockObject
*/
private function getObjectManagerMock()
{
Expand Down Expand Up @@ -234,7 +232,7 @@ private function getObjectManagerMock()
/**
* Client factory mocking.
*
* @return PHPUnit_Framework_MockObject_MockObject
* @return \PHPUnit\Framework\MockObject\MockObject
*/
private function initClientMock()
{
Expand All @@ -251,7 +249,7 @@ private function initClientMock()
/**
* Index settings mocking.
*
* @return PHPUnit_Framework_MockObject_MockObject
* @return \PHPUnit\Framework\MockObject\MockObject
*/
private function getIndexSettingsMock()
{
Expand All @@ -270,7 +268,7 @@ private function getIndexSettingsMock()
/**
* Logger mocking.
*
* @return PHPUnit_Framework_MockObject_MockObject
* @return \PHPUnit\Framework\MockObject\MockObject
*/
private function getLoggerMock()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down Expand Up @@ -116,7 +115,7 @@ public function testIndexingSettings()
/**
* {@inheritDoc}
*/
protected function setUp()
protected function setUp(): void
{
$indexSettingHelper = $this->getIndexSettingsMock();
$indicesConfig = $this->getIndicesConfigMock();
Expand All @@ -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()
{
Expand Down Expand Up @@ -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()
{
Expand All @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion src/module-elasticsuite-core/Test/Unit/Index/IndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class IndexTest extends \PHPUnit\Framework\TestCase
*
* {@inheritDoc}
*/
protected function setUp()
protected function setUp(): void
{
$fieldMock = $this->getMockBuilder(FieldInterface::class)->getMock();

Expand Down
Loading

0 comments on commit 700c580

Please sign in to comment.