Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 5ec1fde

Browse files
author
Reza Shadman
committed
Finish foundation-filters
2 parents 3f32af4 + 35f0d11 commit 5ec1fde

File tree

5 files changed

+52
-45
lines changed

5 files changed

+52
-45
lines changed

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
"Quince\\Pelastic\\": "src/"
2121
}
2222
},
23+
"autoload-dev": {
24+
"psr-4": {
25+
"Quince\\Pelastic\\Tests\\": "test/"
26+
}
27+
},
2328
"require": {
2429
"danielstjules/stringy": "~1.9",
2530
"guzzlehttp/guzzle": "~5.3",
@@ -30,5 +35,5 @@
3035
"phpunit/phpunit": "~4.6",
3136
"mockery/mockery": "1.0.*@dev"
3237
},
33-
"minimum-stability": "stable"
38+
"minimum-stability": "dev"
3439
}

src/Queries/BooleanQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,4 +412,4 @@ public function removeMustNots()
412412

413413
return $this;
414414
}
415-
}
415+
}

src/Queries/FilteredQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,4 @@ public function strategyIsValid($strategy)
183183

184184
return (bool) preg_match($pattern, $strategy);
185185
}
186-
}
186+
}
Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,70 @@
1-
<?php namespace Quince\Pelastic\Tests\Unit;
1+
<?php namespace Quince\Pelastic\Tests\Unit\Queries;
22

3-
use Quince\Pelastic\Exceptions\PelasticInvalidArgumentException;
43
use Quince\Pelastic\Contracts\ArrayableInterface;
54
use Quince\Pelastic\Contracts\Queries\QueryInterface;
65
use Quince\Pelastic\Contracts\Queries\TermQueryInterface;
6+
use Quince\Pelastic\Exceptions\PelasticInvalidArgumentException;
77
use Quince\Pelastic\Queries\TermQuery;
8+
use Quince\Pelastic\Tests\Unit\BaseTestCase;
89

910
class TermQueryTest extends BaseTestCase {
1011

11-
/**
12-
* @var TermQuery
13-
*/
14-
protected $mainObject;
12+
/**
13+
* @var TermQuery
14+
*/
15+
protected $mainObject;
1516

16-
public function setUp()
17-
{
18-
$this->mainObject = new TermQuery('title', 'This is a title');
19-
parent::setUp();
20-
}
17+
public function setUp()
18+
{
19+
$this->mainObject = new TermQuery('title', 'This is a title');
20+
parent::setUp();
21+
}
2122

22-
public function test_class_implements_the_needed_interfaces()
23-
{
24-
$needs = [QueryInterface::class, TermQueryInterface::class, ArrayableInterface::class];
23+
public function test_class_implements_the_needed_interfaces()
24+
{
25+
$needs = [QueryInterface::class, TermQueryInterface::class, ArrayableInterface::class];
2526

26-
foreach ($needs as $need) {
27+
foreach ($needs as $need) {
2728

28-
$this->assertTrue(is_a($this->mainObject, $need));
29+
$this->assertTrue(is_a($this->mainObject, $need));
2930

30-
}
31-
}
31+
}
32+
}
3233

33-
public function test_final_generated_array_with_and_without_construct()
34-
{
35-
$expected = [
36-
'term' => [
37-
'title' => [
38-
'value' => $string = 'some query string'
39-
]
40-
]
41-
];
34+
public function test_final_generated_array_with_and_without_construct()
35+
{
36+
$expected = [
37+
'term' => [
38+
'title' => [
39+
'value' => $string = 'some query string'
40+
]
41+
]
42+
];
4243

43-
$this->mainObject = new TermQuery();
44+
$this->mainObject = new TermQuery();
4445

45-
$this->mainObject->setField('title');
46+
$this->mainObject->setField('title');
4647

47-
$this->mainObject->setQuery($string);
48+
$this->mainObject->setQuery($string);
4849

49-
$this->assertEquals($expected, $this->mainObject->toArray());
50+
$this->assertEquals($expected, $this->mainObject->toArray());
5051

51-
$this->mainObject->setQuery('ss');
52+
$this->mainObject->setQuery('ss');
5253

53-
$this->assertNotEquals($expected, $this->mainObject->toArray());
54+
$this->assertNotEquals($expected, $this->mainObject->toArray());
5455

55-
$this->mainObject->setValue($string);
56+
$this->mainObject->setValue($string);
5657

57-
$this->assertEquals($expected, $this->mainObject->toArray());
58+
$this->assertEquals($expected, $this->mainObject->toArray());
5859

59-
$expected['term']['title']['boost'] = 500;
60+
$expected['term']['title']['boost'] = 500;
6061

61-
$this->mainObject->setBoost(500);
62+
$this->mainObject->setBoost(500);
6263

63-
$this->assertEquals($expected, $this->mainObject->toArray());
64+
$this->assertEquals($expected, $this->mainObject->toArray());
6465

65-
$this->setExpectedException(PelasticInvalidArgumentException::class);
66+
$this->setExpectedException(PelasticInvalidArgumentException::class);
6667

67-
$this->mainObject->setBoost('salam');
68-
}
69-
}
68+
$this->mainObject->setBoost('salam');
69+
}
70+
}

tests/bootstrap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<?php
22

33
require_once rtrim(__DIR__, '/') . '/Unit/BaseTestCase.php';
4+
require_once rtrim(__DIR__, '/') . '/../vendor/autoload.php';

0 commit comments

Comments
 (0)