Skip to content

Commit 4933d66

Browse files
Merge pull request #250 from algolia/debug/travis
Fix Travis build
2 parents 449f3f8 + 44a198d commit 4933d66

4 files changed

Lines changed: 33 additions & 11 deletions

File tree

phpunit.xml.dist

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit colors="true" bootstrap="vendor/autoload.php">
2+
<phpunit colors="true" bootstrap="vendor/autoload.php" convertDeprecationsToExceptions="false">
33
<php>
44
<env name="KERNEL_CLASS" value="Algolia\SearchBundle\Kernel" />
55
<env name="APP_ENV" value="test" />
66
<env name="APP_DEBUG" value="false" />
7-
<env name="ALGOLIA_PREFIX" value="TRAVIS_sf_" />
7+
<env name="ALGOLIA_PREFIX" value="sf_phpunit_" />
8+
<env name="TRAVIS_JOB_NUMBER" value="" />
9+
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled" />
810
</php>
911
<testsuites>
1012
<testsuite name="TestCase">

tests/BaseTest.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,26 @@
22

33
namespace Algolia\SearchBundle;
44

5-
use Algolia\SearchBundle\Doctrine\NullConnection;
6-
use Algolia\SearchBundle\Engine\AlgoliaEngine;
7-
use Algolia\SearchBundle\Engine\AlgoliaSyncEngine;
8-
use Algolia\SearchBundle\Engine\NullEngine;
95
use Algolia\SearchBundle\Entity\Comment;
10-
use AlgoliaSearch\Client;
116
use Algolia\SearchBundle\Entity\Post;
127
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
13-
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
14-
use Symfony\Component\Yaml\Yaml;
158

169
class BaseTest extends KernelTestCase
1710
{
11+
public static function setUpBeforeClass()
12+
{
13+
/*
14+
* Older version of PHPUnit (<6.0) load
15+
* env variables differently, we override them
16+
* here to make sure they're coming from the
17+
* env rather than the XML config
18+
*/
19+
if (class_exists('\PHPUnit_Runner_Version')) {
20+
$_ENV['ALGOLIA_PREFIX'] = getenv('ALGOLIA_PREFIX');
21+
$_ENV['TRAVIS_JOB_NUMBER'] = getenv('TRAVIS_JOB_NUMBER');
22+
}
23+
}
24+
1825
public function setUp()
1926
{
2027
$this->bootKernel();
@@ -60,7 +67,7 @@ protected function createComment($id = null)
6067

6168
protected function getPrefix()
6269
{
63-
return getenv('ALGOLIA_PREFIX');
70+
return $this->get('search.index_manager')->getConfiguration()['prefix'];
6471
}
6572

6673
protected function get($id)

tests/TestCase/AlgoliaEngineTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44

55
class AlgoliaEngineTest extends BaseTest
66
{
7+
/**
8+
*
9+
* Doctrine is currently splitting the common package
10+
* into 3 separate ones, some deprecation notice appeared
11+
* until we can migrate doctrine/common and keep BC
12+
* with PHP 5.6 and Symfony 3.4, we allow deprecation
13+
* notice for this test
14+
*
15+
* https://github.com/doctrine/common/issues/826
16+
*
17+
* @group legacy
18+
*
19+
*/
720
public function testIndexing()
821
{
922
$engine = $this->get('search.engine');

tests/config/algolia_search.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
algolia_search:
2-
prefix: '%env(ALGOLIA_PREFIX)%'
2+
prefix: '%env(ALGOLIA_PREFIX)%%env(TRAVIS_JOB_NUMBER)%_'
33
nbResults: 12
44
batchSize: 100
55
settingsDirectory: '/tests/cache/settings'

0 commit comments

Comments
 (0)