Skip to content

Commit 8959364

Browse files
committed
Unify test conventions
1 parent 215de1a commit 8959364

23 files changed

Lines changed: 154 additions & 154 deletions

tests/Unit/Documents/DocumentManagerTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
$this->documentManager = new DocumentManager($this->client);
1616
});
1717

18-
test('documents can be indexed with refresh', function () {
18+
it('indexes documents with refresh', function () {
1919
$this->client
2020
->expects($this->once())
2121
->method('bulk')
@@ -43,7 +43,7 @@
4343
$this->assertSame($this->documentManager, $this->documentManager->index('test', $documents, true));
4444
});
4545

46-
test('documents can be indexed without refresh', function () {
46+
it('indexes documents without refresh', function () {
4747
$this->client
4848
->expects($this->once())
4949
->method('bulk')
@@ -68,7 +68,7 @@
6868
$this->assertSame($this->documentManager, $this->documentManager->index('test', $documents, false));
6969
});
7070

71-
test('documents can be indexed with custom routing', function () {
71+
it('indexes documents with custom routing', function () {
7272
$this->client
7373
->expects($this->once())
7474
->method('bulk')
@@ -99,7 +99,7 @@
9999
$this->assertSame($this->documentManager, $this->documentManager->index('test', $documents, true, $routing));
100100
});
101101

102-
test('documents can be deleted with refresh', function () {
102+
it('deletes documents with refresh', function () {
103103
$this->client
104104
->expects($this->once())
105105
->method('bulk')
@@ -122,7 +122,7 @@
122122
$this->assertSame($this->documentManager, $this->documentManager->delete('test', $ids, true));
123123
});
124124

125-
test('documents can be deleted without refresh', function () {
125+
it('deletes documents without refresh', function () {
126126
$this->client
127127
->expects($this->once())
128128
->method('bulk')
@@ -144,7 +144,7 @@
144144
$this->assertSame($this->documentManager, $this->documentManager->delete('test', $ids, false));
145145
});
146146

147-
test('documents can be deleted with custom routing', function () {
147+
it('deletes documents with custom routing', function () {
148148
$this->client
149149
->expects($this->once())
150150
->method('bulk')
@@ -170,7 +170,7 @@
170170
$this->assertSame($this->documentManager, $this->documentManager->delete('test', $ids, true, $routing));
171171
});
172172

173-
test('documents can be deleted by query with refresh', function () {
173+
it('deletes documents by query with refresh', function () {
174174
$this->client
175175
->expects($this->once())
176176
->method('deleteByQuery')
@@ -189,7 +189,7 @@
189189
$this->assertSame($this->documentManager, $this->documentManager->deleteByQuery('test', $query, true));
190190
});
191191

192-
test('documents can be deleted by query without refresh', function () {
192+
it('deletes documents by query without refresh', function () {
193193
$this->client
194194
->expects($this->once())
195195
->method('deleteByQuery')
@@ -208,7 +208,7 @@
208208
$this->assertSame($this->documentManager, $this->documentManager->deleteByQuery('test', $query, false));
209209
});
210210

211-
test('documents can be found', function () {
211+
it('finds documents', function () {
212212
$this->client
213213
->expects($this->once())
214214
->method('search')
@@ -246,7 +246,7 @@
246246
$this->assertEquals(new Document('1', ['content' => 'foo']), $response->hits()[0]->document());
247247
});
248248

249-
test('exception is thrown when index operation was unsuccessful', function () {
249+
it('throws an exception when an index operation is unsuccessful', function () {
250250
$this->client
251251
->expects($this->once())
252252
->method('bulk')

tests/Unit/Documents/DocumentRoutingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use DirectoryTree\OpenSearchAdapter\Documents\DocumentRouting;
66

7-
test('routing values can be added and retrieved', function () {
7+
it('adds and retrieves routing values', function () {
88
$routing = DocumentRouting::make('1', 'user1')
99
->add('2', 'user2');
1010

tests/Unit/Documents/DocumentTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use DirectoryTree\OpenSearchAdapter\Documents\Document;
66

7-
test('document getters', function () {
7+
it('retrieves document values', function () {
88
$document = new Document('123456', ['title' => 'book', 'price' => 10]);
99

1010
$this->assertSame('123456', $document->id());
@@ -13,14 +13,14 @@
1313
$this->assertNull($document->get('missing'));
1414
});
1515

16-
test('fake document can be created', function () {
16+
it('creates a fake document', function () {
1717
$document = Document::fake('123456', ['title' => 'book']);
1818

1919
expect($document->id())->toBe('123456')
2020
->and($document->source())->toBe(['title' => 'book']);
2121
});
2222

23-
test('array casting', function () {
23+
it('casts to an array', function () {
2424
$document = new Document('1', ['title' => 'test']);
2525

2626
$this->assertSame([
@@ -29,7 +29,7 @@
2929
], $document->toArray());
3030
});
3131

32-
test('bulk index payload can be retrieved', function () {
32+
it('retrieves bulk index payload', function () {
3333
$document = new Document('1', ['title' => 'test']);
3434

3535
$this->assertSame([
@@ -38,7 +38,7 @@
3838
], $document->toBulkIndex());
3939
});
4040

41-
test('bulk index payload can be retrieved with routing', function () {
41+
it('retrieves bulk index payload with routing', function () {
4242
$document = new Document('1', ['title' => 'test']);
4343

4444
$this->assertSame([

tests/Unit/Documents/FakeDocumentManagerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
use DirectoryTree\OpenSearchAdapter\Search\SearchResponse;
88
use DirectoryTree\OpenSearchAdapter\Testing\Fakes\FakeDocumentManager;
99

10-
test('fake document manager implements the document manager contract', function () {
10+
it('implements the document manager contract', function () {
1111
expect(new FakeDocumentManager)->toBeInstanceOf(DocumentManagerInterface::class);
1212
});
1313

14-
test('fake document manager records indexed documents', function () {
14+
it('records indexed documents', function () {
1515
$documents = [
1616
new Document('1', ['title' => 'First']),
1717
new Document('2', ['title' => 'Second']),
@@ -27,7 +27,7 @@
2727
$documentsManager->assertIndexed('posts', $documents, true, $routing);
2828
});
2929

30-
test('fake document manager records deleted documents', function () {
30+
it('records deleted documents', function () {
3131
$routing = DocumentRouting::make('1', 'tenant-1')
3232
->add('2', 'tenant-2');
3333

@@ -38,7 +38,7 @@
3838
$documents->assertDeleted('posts', ['1', '2'], true, $routing);
3939
});
4040

41-
test('fake document manager records delete by query operations', function () {
41+
it('records delete-by-query operations', function () {
4242
$documents = new FakeDocumentManager;
4343

4444
$documents->deleteByQuery('posts', $query = [
@@ -50,7 +50,7 @@
5050
$documents->assertDeletedByQuery('posts', $query, true);
5151
});
5252

53-
test('fake document manager records searches and returns configured responses', function () {
53+
it('records searches and returns configured responses', function () {
5454
$request = new SearchRequest([
5555
'match' => [
5656
'title' => 'OpenSearch',
@@ -84,7 +84,7 @@
8484
$documents->assertSearched('posts', $request);
8585
});
8686

87-
test('fake document manager can be constructed with a search response', function () {
87+
it('creates a fake document manager with a search response', function () {
8888
$documents = new FakeDocumentManager($response = SearchResponse::fake());
8989

9090
expect($documents->search('posts', new SearchRequest))->toBe($response);

tests/Unit/Exceptions/BulkRequestExceptionTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use DirectoryTree\OpenSearchAdapter\Exceptions\BulkRequestException;
66

7-
test('response can be retrieved', function () {
7+
it('retrieves response', function () {
88
$response = [
99
'took' => 486,
1010
'errors' => true,
@@ -32,7 +32,7 @@
3232
$this->assertSame($response, $exception->response());
3333
});
3434

35-
test('first error message from response is given in exception message', function () {
35+
it('uses the first response error as the exception message', function () {
3636
$response = [
3737
'took' => 486,
3838
'errors' => true,
@@ -63,7 +63,7 @@
6363
);
6464
});
6565

66-
test('exception can be thrown with many errors in response', function () {
66+
it('throws an exception when the response contains multiple errors', function () {
6767
$response = [
6868
'took' => 486,
6969
'errors' => true,
@@ -109,7 +109,7 @@
109109
);
110110
});
111111

112-
test('exception can be thrown with missing error in response', function () {
112+
it('throws an exception when the response omits an error', function () {
113113
$response = [
114114
'took' => 486,
115115
'errors' => true,
@@ -133,7 +133,7 @@
133133
);
134134
});
135135

136-
test('exception can be thrown with missing items in response', function () {
136+
it('throws an exception when the response omits items', function () {
137137
$response = [
138138
'took' => 486,
139139
'errors' => true,

tests/Unit/Indices/AliasActionsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use DirectoryTree\OpenSearchAdapter\Indices\Alias;
66
use DirectoryTree\OpenSearchAdapter\Indices\AliasActions;
77

8-
test('alias actions can be built', function () {
8+
it('builds alias actions', function () {
99
$actions = (new AliasActions)
1010
->remove('posts_blue', 'posts')
1111
->add('posts_green', new Alias('posts', isWriteIndex: true))
@@ -35,7 +35,7 @@
3535
]);
3636
});
3737

38-
test('add actions include alias routing and filters', function () {
38+
it('includes alias routing and filters in add actions', function () {
3939
$actions = (new AliasActions)->add(
4040
'posts',
4141
new Alias(

tests/Unit/Indices/AliasTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44

55
use DirectoryTree\OpenSearchAdapter\Indices\Alias;
66

7-
test('alias getters', function () {
7+
it('retrieves alias values', function () {
88
$alias = new Alias('2030', ['term' => ['year' => 2030]], 'year');
99

1010
$this->assertSame('2030', $alias->name());
1111
$this->assertSame(['term' => ['year' => 2030]], $alias->filter());
1212
$this->assertSame('year', $alias->routing());
1313
});
1414

15-
test('array casting without filter and routing', function () {
15+
it('casts to an array without a filter or routing', function () {
1616
$alias = new Alias('2030');
1717

1818
$this->assertSame([], $alias->toArray());
1919
});
2020

21-
test('array casting with filter and routing', function () {
21+
it('casts to an array with a filter and routing', function () {
2222
$alias = new Alias('2030', ['term' => ['year' => 2030]], 'year');
2323

2424
$this->assertSame([
@@ -31,7 +31,7 @@
3131
], $alias->toArray());
3232
});
3333

34-
test('write index can be configured', function () {
34+
it('configures write index', function () {
3535
$alias = new Alias('2030', isWriteIndex: true);
3636

3737
expect($alias->isWriteIndex())->toBeTrue()
@@ -40,7 +40,7 @@
4040
]);
4141
});
4242

43-
test('write index false is included in the payload', function () {
43+
it('includes a false write index in the payload', function () {
4444
$alias = new Alias('2030', isWriteIndex: false);
4545

4646
expect($alias->isWriteIndex())->toBeFalse()

tests/Unit/Indices/FakeIndexManagerTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
use DirectoryTree\OpenSearchAdapter\Indices\Settings;
99
use DirectoryTree\OpenSearchAdapter\Testing\Fakes\FakeIndexManager;
1010

11-
test('fake index manager implements the index manager contract', function () {
11+
it('implements the index manager contract', function () {
1212
expect(new FakeIndexManager)->toBeInstanceOf(IndexManagerInterface::class);
1313
});
1414

15-
test('fake index manager tracks index existence', function () {
15+
it('tracks index existence', function () {
1616
$indices = new FakeIndexManager;
1717

1818
expect($indices->exists('posts'))->toBeFalse();
@@ -24,7 +24,7 @@
2424
expect($indices->exists('posts'))->toBeTrue();
2525
});
2626

27-
test('fake index manager records created indices', function () {
27+
it('records created indices', function () {
2828
$indices = new FakeIndexManager;
2929

3030
$indices->create($index = new IndexBlueprint(
@@ -38,23 +38,23 @@
3838
expect($indices->exists('posts'))->toBeTrue();
3939
});
4040

41-
test('fake index manager records mapping updates', function () {
41+
it('records mapping updates', function () {
4242
$indices = new FakeIndexManager;
4343

4444
$indices->putMapping('posts', $mapping = (new Mapping)->keyword('status'));
4545

4646
$indices->assertMappingPut('posts', $mapping);
4747
});
4848

49-
test('fake index manager records settings updates', function () {
49+
it('records settings updates', function () {
5050
$indices = new FakeIndexManager;
5151

5252
$indices->putSettings('posts', $settings = (new Settings)->index(['refresh_interval' => -1]));
5353

5454
$indices->assertSettingsPut('posts', $settings);
5555
});
5656

57-
test('fake index manager records open and close operations', function () {
57+
it('records open and close operations', function () {
5858
$indices = new FakeIndexManager;
5959

6060
$indices
@@ -64,7 +64,7 @@
6464
->assertOpened('posts');
6565
});
6666

67-
test('fake index manager records deleted indices', function () {
67+
it('records deleted indices', function () {
6868
$indices = new FakeIndexManager(existing: ['posts']);
6969

7070
$indices->delete('posts');
@@ -74,7 +74,7 @@
7474
expect($indices->exists('posts'))->toBeFalse();
7575
});
7676

77-
test('fake index manager records aliases', function () {
77+
it('records aliases', function () {
7878
$indices = new FakeIndexManager;
7979

8080
$alias = new Alias('published_posts', [
@@ -90,7 +90,7 @@
9090
]);
9191
});
9292

93-
test('fake index manager records deleted aliases', function () {
93+
it('records deleted aliases', function () {
9494
$indices = new FakeIndexManager;
9595

9696
$indices->putAlias('posts', new Alias('published_posts'));
@@ -102,7 +102,7 @@
102102
expect($indices->getAliases('posts'))->toBe([]);
103103
});
104104

105-
test('fake index manager applies atomic alias updates', function () {
105+
it('applies atomic alias updates', function () {
106106
$indices = new FakeIndexManager(existing: [
107107
'posts_blue',
108108
'posts_green',

0 commit comments

Comments
 (0)