-
Notifications
You must be signed in to change notification settings - Fork 4
/
RavenDB_5669Test.php
107 lines (83 loc) · 3.07 KB
/
RavenDB_5669Test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
namespace tests\RavenDB\Test\Client\Issues\RavenDB_5669Test;
use RavenDB\Documents\DocumentStore;
use tests\RavenDB\RemoteTestBase;
use tests\RavenDB\Test\Client\Issues\RavenDB_5669Test\Entity\Animal;
use tests\RavenDB\Test\Client\Issues\RavenDB_5669Test\Entity\Animal_Index;
class RavenDB_5669Test extends RemoteTestBase
{
public function testWorkingTestWithDifferentSearchTermOrder(): void
{
$store = $this->getDocumentStore();
try {
$store->executeIndex(new Animal_Index());
$this->storeAnimals($store);
$session = $store->openSession();
try {
$query = $session->advanced()->documentQuery(Animal::class, Animal_Index::class);
$query->openSubclause();
$query = $query->whereEquals("type", "Cat");
$query = $query->orElse();
$query = $query->search("name", "Peter*");
$query = $query->andAlso();
$query = $query->search("name", "Pan*");
$query->closeSubclause();
$results = $query->toList();
$this->assertCount(1, $results);
} finally {
$session->close();
}
} finally {
$store->close();
}
}
public function testWorkingTestWithSubclause(): void
{
$store = $this->getDocumentStore();
try {
$store->executeIndex(new Animal_Index());
$this->storeAnimals($store);
$session = $store->openSession();
try {
$query = $session->advanced()->documentQuery(Animal::class, Animal_Index::class);
$query->openSubclause();
$query = $query->whereEquals("type", "Cat");
$query = $query->orElse();
$query->openSubclause();
$query = $query->search("name", "Pan*");
$query = $query->andAlso();
$query = $query->search("name", "Peter*");
$query = $query->closeSubclause();
$query->closeSubclause();
$results = $query->toList();
$this->assertCount(1, $results);
} finally {
$session->close();
}
} finally {
$store->close();
}
}
private function storeAnimals(DocumentStore $store): void
{
$session = $store->openSession();
try {
$animal1 = new Animal();
$animal1->setName("Peter Pan");
$animal1->setType("Dog");
$animal2 = new Animal();
$animal2->setName("Peter Poo");
$animal2->setType("Dog");
$animal3 = new Animal();
$animal3->setName("Peter Foo");
$animal3->setType("Dog");
$session->store($animal1);
$session->store($animal2);
$session->store($animal3);
$session->saveChanges();
} finally {
$session->close();
}
$this->waitForIndexing($store, $store->getDatabase());
}
}