Skip to content

Commit 0739eed

Browse files
committed
Fix tests
1 parent d0cb229 commit 0739eed

File tree

8 files changed

+205
-32
lines changed

8 files changed

+205
-32
lines changed

tests/SpameriTests/ElasticQuery/Mapping/Analyzer/Custom/CzechDictionary.phpt

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ class CzechDictionary extends \Tester\TestCase
1414

1515
public function testCreate() : void
1616
{
17+
$settings = new \Spameri\ElasticQuery\Mapping\Settings(self::INDEX);
18+
$settings->addAnalyzer(new \Spameri\ElasticQuery\Mapping\Analyzer\Custom\CzechDictionary());
1719
$document = new \Spameri\ElasticQuery\Document(
1820
self::INDEX,
19-
new \Spameri\ElasticQuery\Document\Body\Settings(
20-
new \Spameri\ElasticQuery\Mapping\Settings\Analysis\AnalyzerCollection(
21-
new \Spameri\ElasticQuery\Mapping\Analyzer\Custom\CzechDictionary()
22-
),
23-
new \Spameri\ElasticQuery\Mapping\Settings\Analysis\FilterCollection()
21+
new \Spameri\ElasticQuery\Document\Body\Plain(
22+
$settings->toArray()
2423
)
2524
);
2625

@@ -36,10 +35,7 @@ class CzechDictionary extends \Tester\TestCase
3635
\json_encode($document->toArray()['body'])
3736
);
3837

39-
$response = curl_exec($ch);
40-
41-
// \var_dump($response);
42-
38+
curl_exec($ch);
4339

4440
// Fetch settings and test if analyzer is configured
4541

@@ -49,17 +45,15 @@ class CzechDictionary extends \Tester\TestCase
4945

5046
$responseSettings = \json_decode(curl_exec($ch), TRUE);
5147

52-
\var_dump($responseSettings);
53-
5448
\Tester\Assert::true(isset(
5549
$responseSettings[self::INDEX]['settings']['index']['analysis']['analyzer']['czechDictionary']
5650
));
5751
\Tester\Assert::same(
58-
'removeDuplicities',
59-
$responseSettings[self::INDEX]['settings']['index']['analysis']['analyzer']['czechDictionary'][2]
52+
'dictionary_CZ',
53+
$responseSettings[self::INDEX]['settings']['index']['analysis']['analyzer']['czechDictionary']['filter'][2]
6054
);
6155
\Tester\Assert::same(
62-
'standard',
56+
'custom',
6357
$responseSettings[self::INDEX]['settings']['index']['analysis']['analyzer']['czechDictionary']['type']
6458
);
6559

@@ -81,17 +75,15 @@ class CzechDictionary extends \Tester\TestCase
8175

8276
protected function tearDown(): void
8377
{
84-
$ch = curl_init();
85-
curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . self::INDEX);
86-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
87-
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
88-
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
78+
$ch = \curl_init();
79+
\curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . self::INDEX);
80+
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
81+
\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
82+
\curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
8983

90-
$response = curl_exec($ch);
84+
\curl_exec($ch);
9185

92-
// \var_dump($response);
93-
94-
curl_close($ch);
86+
\curl_close($ch);
9587
}
9688

9789
}

tests/SpameriTests/ElasticQuery/Query/Fuzzy.phpt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,20 @@ require_once __DIR__ . '/../../bootstrap.php';
88
class Fuzzy extends \Tester\TestCase
99
{
1010

11-
private const SPAMERI_VIDEO = 'spameri_test_video';
11+
private const SPAMERI_VIDEO = 'spameri_test_video_fuzzy';
12+
13+
14+
public function setUp() : void
15+
{
16+
$ch = \curl_init();
17+
\curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . self::SPAMERI_VIDEO);
18+
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
19+
\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
20+
\curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
21+
22+
\curl_exec($ch);
23+
\curl_close($ch);
24+
}
1225

1326

1427
public function testCreate() : void
@@ -68,6 +81,19 @@ class Fuzzy extends \Tester\TestCase
6881
curl_close($ch);
6982
}
7083

84+
85+
public function tearDown() : void
86+
{
87+
$ch = \curl_init();
88+
\curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . self::SPAMERI_VIDEO);
89+
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
90+
\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
91+
\curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
92+
93+
\curl_exec($ch);
94+
\curl_close($ch);
95+
}
96+
7197
}
7298

7399
(new Fuzzy())->run();

tests/SpameriTests/ElasticQuery/Query/Match.phpt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,20 @@ require_once __DIR__ . '/../../bootstrap.php';
88
class Match extends \Tester\TestCase
99
{
1010

11-
private const SPAMERI_VIDEO = 'spameri_test_video';
11+
private const SPAMERI_VIDEO = 'spameri_test_video_match';
12+
13+
14+
public function setUp() : void
15+
{
16+
$ch = \curl_init();
17+
\curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . self::SPAMERI_VIDEO);
18+
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
19+
\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
20+
\curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
21+
22+
\curl_exec($ch);
23+
\curl_close($ch);
24+
}
1225

1326

1427
public function testCreate() : void
@@ -72,6 +85,19 @@ class Match extends \Tester\TestCase
7285
curl_close($ch);
7386
}
7487

88+
89+
public function tearDown() : void
90+
{
91+
$ch = \curl_init();
92+
\curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . self::SPAMERI_VIDEO);
93+
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
94+
\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
95+
\curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
96+
97+
\curl_exec($ch);
98+
\curl_close($ch);
99+
}
100+
75101
}
76102

77103
(new Match())->run();

tests/SpameriTests/ElasticQuery/Query/MatchPhrase.phpt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,20 @@ require_once __DIR__ . '/../../bootstrap.php';
88
class MatchPhrase extends \Tester\TestCase
99
{
1010

11-
private const SPAMERI_VIDEO = 'spameri_test_video';
11+
private const SPAMERI_VIDEO = 'spameri_test_video_match_phrase';
12+
13+
14+
public function setUp() : void
15+
{
16+
$ch = \curl_init();
17+
\curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . self::SPAMERI_VIDEO);
18+
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
19+
\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
20+
\curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
21+
22+
\curl_exec($ch);
23+
\curl_close($ch);
24+
}
1225

1326

1427
public function testCreate() : void
@@ -66,6 +79,19 @@ class MatchPhrase extends \Tester\TestCase
6679
curl_close($ch);
6780
}
6881

82+
83+
public function tearDown() : void
84+
{
85+
$ch = \curl_init();
86+
\curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . self::SPAMERI_VIDEO);
87+
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
88+
\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
89+
\curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
90+
91+
\curl_exec($ch);
92+
\curl_close($ch);
93+
}
94+
6995
}
7096

7197
(new MatchPhrase())->run();

tests/SpameriTests/ElasticQuery/Query/Range.phpt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,20 @@ require_once __DIR__ . '/../../bootstrap.php';
88
class Range extends \Tester\TestCase
99
{
1010

11-
private const SPAMERI_VIDEO = 'spameri_test_video';
11+
private const SPAMERI_VIDEO = 'spameri_test_video_range';
12+
13+
14+
public function setUp() : void
15+
{
16+
$ch = \curl_init();
17+
\curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . self::SPAMERI_VIDEO);
18+
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
19+
\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
20+
\curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
21+
22+
\curl_exec($ch);
23+
\curl_close($ch);
24+
}
1225

1326

1427
public function testCreate() : void
@@ -64,6 +77,19 @@ class Range extends \Tester\TestCase
6477
curl_close($ch);
6578
}
6679

80+
81+
public function tearDown() : void
82+
{
83+
$ch = \curl_init();
84+
\curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . self::SPAMERI_VIDEO);
85+
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
86+
\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
87+
\curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
88+
89+
\curl_exec($ch);
90+
\curl_close($ch);
91+
}
92+
6793
}
6894

6995
(new Range())->run();

tests/SpameriTests/ElasticQuery/Query/Term.phpt

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,20 @@ require_once __DIR__ . '/../../bootstrap.php';
88
class Term extends \Tester\TestCase
99
{
1010

11-
private const SPAMERI_VIDEO = 'spameri_test_video';
11+
private const SPAMERI_VIDEO = 'spameri_test_video_term';
12+
13+
14+
public function setUp() : void
15+
{
16+
$ch = \curl_init();
17+
\curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . self::SPAMERI_VIDEO);
18+
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
19+
\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
20+
\curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
21+
22+
\curl_exec($ch);
23+
\curl_close($ch);
24+
}
1225

1326

1427
public function testCreate() : void
@@ -42,7 +55,7 @@ class Term extends \Tester\TestCase
4255
);
4356

4457
$ch = curl_init();
45-
curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . $document->index() . '_search');
58+
curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . $document->index() . '/_search');
4659
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
4760
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
4861
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
@@ -62,6 +75,19 @@ class Term extends \Tester\TestCase
6275
curl_close($ch);
6376
}
6477

78+
79+
public function tearDown() : void
80+
{
81+
$ch = \curl_init();
82+
\curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . self::SPAMERI_VIDEO);
83+
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
84+
\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
85+
\curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
86+
87+
\curl_exec($ch);
88+
\curl_close($ch);
89+
}
90+
6591
}
6692

6793
(new Term())->run();

tests/SpameriTests/ElasticQuery/Query/Terms.phpt

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,21 @@ require_once __DIR__ . '/../../bootstrap.php';
88
class Terms extends \Tester\TestCase
99
{
1010

11-
private const SPAMERI_VIDEO = 'spameri_test_video';
11+
private const SPAMERI_VIDEO = 'spameri_test_video_terms';
1212

1313

14+
public function setUp() : void
15+
{
16+
$ch = \curl_init();
17+
\curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . self::SPAMERI_VIDEO);
18+
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
19+
\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
20+
\curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
21+
22+
\curl_exec($ch);
23+
\curl_close($ch);
24+
}
25+
1426
public function testCreate() : void
1527
{
1628
$terms = new \Spameri\ElasticQuery\Query\Terms(
@@ -62,6 +74,19 @@ class Terms extends \Tester\TestCase
6274
curl_close($ch);
6375
}
6476

77+
78+
public function tearDown() : void
79+
{
80+
$ch = \curl_init();
81+
\curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . self::SPAMERI_VIDEO);
82+
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
83+
\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
84+
\curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
85+
86+
\curl_exec($ch);
87+
\curl_close($ch);
88+
}
89+
6590
}
6691

6792
(new Terms())->run();

tests/SpameriTests/ElasticQuery/Query/WildCard.phpt

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,20 @@ require_once __DIR__ . '/../../bootstrap.php';
88
class WildCard extends \Tester\TestCase
99
{
1010

11-
private const SPAMERI_VIDEO = 'spameri_test_video';
11+
private const SPAMERI_VIDEO = 'spameri_test_video_wildcard';
12+
13+
14+
public function setUp() : void
15+
{
16+
$ch = \curl_init();
17+
\curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . self::SPAMERI_VIDEO);
18+
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
19+
\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
20+
\curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
21+
22+
\curl_exec($ch);
23+
\curl_close($ch);
24+
}
1225

1326

1427
public function testCreate() : void
@@ -42,7 +55,7 @@ class WildCard extends \Tester\TestCase
4255
);
4356

4457
$ch = curl_init();
45-
curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . $document->index() . '_search');
58+
curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . $document->index() . '/_search');
4659
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
4760
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
4861
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
@@ -62,6 +75,19 @@ class WildCard extends \Tester\TestCase
6275
curl_close($ch);
6376
}
6477

78+
79+
public function tearDown() : void
80+
{
81+
$ch = \curl_init();
82+
\curl_setopt($ch, CURLOPT_URL, 'localhost:9200/' . self::SPAMERI_VIDEO);
83+
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
84+
\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
85+
\curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
86+
87+
\curl_exec($ch);
88+
\curl_close($ch);
89+
}
90+
6591
}
6692

6793
(new WildCard())->run();

0 commit comments

Comments
 (0)