Skip to content

Commit 9a9f8ee

Browse files
committed
Test index rebuild setup.
1 parent 6eb4b09 commit 9a9f8ee

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

phpunit.xml.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
44
backupGlobals="false"
55
backupStaticAttributes="false"
66
bootstrap="vendor/autoload.php"
@@ -24,6 +24,7 @@
2424

2525
<php>
2626
<server name="ELASTICSEARCH_HOSTS" value="http://127.0.0.1:9200"/>
27+
<server name="RECREATE_INDEX" value="true"/>
2728
</php>
2829

2930
<coverage processUncoveredFiles="true">

tests/Functional/ElasticTestCase.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ protected function getPackageProviders($app): array
1818
];
1919
}
2020

21+
protected function getEnvironmentSetUp($app)
22+
{
23+
config()->set('tests.recreate_index', env('RECREATE_INDEX', true));
24+
}
25+
2126
protected function tearDown(): void
2227
{
2328
ElasticQuery::disableQueryLog();

tests/Seeds/IndexSeeder.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@ abstract class IndexSeeder
1111
protected array $settings = [];
1212
protected array $fixtures = [];
1313

14-
protected bool $recreate = false;
14+
protected bool $recreate;
1515

1616
protected ?Client $client;
1717

18+
public function __construct()
19+
{
20+
$this->recreate = config('tests.recreate_index', true);
21+
}
22+
1823
public function setClient(Client $client): void
1924
{
2025
$this->client = $client;
@@ -78,6 +83,8 @@ protected function loadFixtures(): void
7883
foreach ($this->fixtures as $fixture) {
7984
$this->loadFixture($baseDir.$fixture);
8085
}
86+
87+
sleep(1);
8188
}
8289

8390
protected function loadFixture(string $path): void

0 commit comments

Comments
 (0)