diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3711e5a3..5e49307a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,10 +1,11 @@ - + - + + diff --git a/tests/BaseTest.php b/tests/BaseTest.php index c8b43223..362186bc 100644 --- a/tests/BaseTest.php +++ b/tests/BaseTest.php @@ -2,19 +2,37 @@ namespace Algolia\SearchBundle; -use Algolia\SearchBundle\Doctrine\NullConnection; -use Algolia\SearchBundle\Engine\AlgoliaEngine; -use Algolia\SearchBundle\Engine\AlgoliaSyncEngine; -use Algolia\SearchBundle\Engine\NullEngine; use Algolia\SearchBundle\Entity\Comment; -use AlgoliaSearch\Client; use Algolia\SearchBundle\Entity\Post; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -use Symfony\Component\Yaml\Yaml; class BaseTest extends KernelTestCase { + public static function setUpBeforeClass() + { + /* + * Older version of PHPUnit (<6.0) load + * env variables differently, we override them + * here to make sure they're coming from the + * env rather than the XML config + */ + if (class_exists('\PHPUnit_Runner_Version')) { + $_ENV['ALGOLIA_PREFIX'] = getenv('ALGOLIA_PREFIX'); + $_ENV['TRAVIS_JOB_NUMBER'] = getenv('TRAVIS_JOB_NUMBER'); + } + + /* + * Doctrine is currently splitting the common package + * into 3 separate ones, some deprecation notice appeared + * until we can migrate doctrine/common and keep BC + * with PHP 5.6 and Symfony 3.4, we allow deprecation + * notice in PHPUnit + */ + if (class_exists('\PHPUnit\Framework\Error\Deprecated')) { + \PHPUnit\Framework\Error\Deprecated::$enabled = false; + } + } + public function setUp() { $this->bootKernel(); @@ -60,7 +78,7 @@ protected function createComment($id = null) protected function getPrefix() { - return getenv('ALGOLIA_PREFIX'); + return $this->get('search.index_manager')->getConfiguration()['prefix']; } protected function get($id) diff --git a/tests/config/algolia_search.yml b/tests/config/algolia_search.yml index 76aa64cd..b70af596 100644 --- a/tests/config/algolia_search.yml +++ b/tests/config/algolia_search.yml @@ -1,5 +1,5 @@ algolia_search: - prefix: '%env(ALGOLIA_PREFIX)%' + prefix: '%env(ALGOLIA_PREFIX)%%env(TRAVIS_JOB_NUMBER)%_' nbResults: 12 batchSize: 100 settingsDirectory: '/tests/cache/settings'