Skip to content

Commit acd7900

Browse files
committed
CLOUDTECH-5 fix tests
1 parent f833742 commit acd7900

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

tests/Data/Models/ProductsIndex.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,21 @@
33
namespace Ensi\LaravelElasticQuery\Tests\Data\Models;
44

55
use Ensi\LaravelElasticQuery\ElasticIndex;
6+
use Illuminate\Support\Facades\ParallelTesting;
67

78
class ProductsIndex extends ElasticIndex
89
{
910
protected string $name = 'test_products';
1011

1112
protected string $tiebreaker = 'product_id';
13+
14+
protected function indexName(): string
15+
{
16+
return $this->name . (ParallelTesting::token() ?: 0);
17+
}
18+
19+
public static function fullName(): string
20+
{
21+
return (new static())->indexName();
22+
}
1223
}

tests/Data/Seeds/IndexSeeder.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
namespace Ensi\LaravelElasticQuery\Tests\Data\Seeds;
44

55
use Ensi\LaravelElasticQuery\ElasticClient;
6-
use Illuminate\Support\Facades\ParallelTesting;
76

87
abstract class IndexSeeder
98
{
10-
protected string $indexName = '';
119
protected array $mappings = [];
1210
protected array $settings = [];
1311
protected array $fixtures = [];
@@ -21,6 +19,8 @@ public function __construct()
2119
$this->recreate = config('tests.recreate_index', true);
2220
}
2321

22+
abstract protected function getIndexName(): string;
23+
2424
public function setClient(ElasticClient $client): void
2525
{
2626
$this->client = $client;
@@ -112,9 +112,4 @@ protected function documentToCommand(array $document, int $id): array
112112
$document,
113113
];
114114
}
115-
116-
protected function getIndexName(): string
117-
{
118-
return $this->indexName . (ParallelTesting::token() ?: 0);
119-
}
120115
}

tests/Data/Seeds/ProductIndexSeeder.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Ensi\LaravelElasticQuery\Tests\Data\Seeds;
44

5+
use Ensi\LaravelElasticQuery\Tests\Data\Models\ProductsIndex;
6+
57
class ProductIndexSeeder extends IndexSeeder
68
{
7-
protected string $indexName = 'test_products';
8-
99
protected array $fixtures = ['products_default.json'];
1010

1111
protected array $settings = [
@@ -60,4 +60,9 @@ class ProductIndexSeeder extends IndexSeeder
6060
],
6161
],
6262
];
63+
64+
protected function getIndexName(): string
65+
{
66+
return ProductsIndex::fullName();
67+
}
6368
}

0 commit comments

Comments
 (0)