Skip to content

Commit 2398283

Browse files
committed
Fixed PHPUnit complaints of risky tests with no assertions.
1 parent c677cde commit 2398283

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

tests/PostgresEngineTest.php

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,25 @@ public function update_adds_object_to_index()
3232
[$engine, $db] = $this->getEngine();
3333

3434
$db->shouldReceive('query')
35-
->andReturn($query = Mockery::mock('stdClass'));
35+
->andReturn($query = Mockery::mock('stdClass'))->once();
3636
$query->shouldReceive('selectRaw')
3737
->with(
3838
'to_tsvector(COALESCE(?, get_current_ts_config()), ?) || setweight(to_tsvector(COALESCE(?, get_current_ts_config()), ?), ?) AS tsvector',
3939
[null, 'Foo', null, '', 'B']
4040
)
41-
->andReturnSelf();
41+
->andReturnSelf()->once();
4242
$query->shouldReceive('value')
4343
->with('tsvector')
44-
->andReturn('foo');
44+
->andReturn('foo')->once();
4545

4646
$db->shouldReceive('table')
4747
->andReturn($table = Mockery::mock('stdClass'));
4848
$table->shouldReceive('where')
4949
->with('id', '=', 1)
50-
->andReturnSelf();
50+
->andReturnSelf()->once();
5151

5252
$table->shouldReceive('update')
53-
->with(['searchable' => 'foo']);
53+
->with(['searchable' => 'foo'])->once();
5454

5555
$engine->update(Collection::make([new TestModel]));
5656
}
@@ -62,7 +62,7 @@ public function update_do_nothing_if_index_maintenance_turned_off_globally()
6262
{
6363
[$engine] = $this->getEngine(['maintain_index' => false]);
6464

65-
$engine->update(Collection::make([new TestModel]));
65+
$this->assertNull($engine->update(Collection::make([new TestModel])));
6666
}
6767

6868
/**
@@ -73,12 +73,15 @@ public function delete_removes_object_from_index()
7373
[$engine, $db] = $this->getEngine();
7474

7575
$db->shouldReceive('table')
76-
->andReturn($table = Mockery::mock('stdClass'));
76+
->andReturn($table = Mockery::mock('stdClass'))
77+
->once();
7778
$table->shouldReceive('whereIn')
7879
->with('id', [1])
79-
->andReturnSelf();
80+
->andReturnSelf()
81+
->once();
8082
$table->shouldReceive('update')
81-
->with(['searchable' => null]);
83+
->with(['searchable' => null])
84+
->once();
8285

8386
$engine->delete(Collection::make([new TestModel]));
8487
}
@@ -142,7 +145,8 @@ public function search()
142145
->shouldReceive('getBindings')->andReturn([null, 'foo', 1, 'qux']);
143146

144147
$db->shouldReceive('select')
145-
->with(null, $table->getBindings());
148+
->with(null, $table->getBindings())
149+
->once();
146150

147151
$builder = new Builder(new TestModel, 'foo');
148152
$builder->where('bar', 1)
@@ -166,7 +170,8 @@ public function search_with_order_by()
166170
->shouldReceive('getBindings')->andReturn([null, 'foo']);
167171

168172
$db->shouldReceive('select')
169-
->with(null, $table->getBindings());
173+
->with(null, $table->getBindings())
174+
->once();
170175

171176
$builder = new Builder(new TestModel, 'foo');
172177
$builder->orderBy('bar', 'desc')
@@ -191,7 +196,7 @@ public function search_with_global_config()
191196
->shouldReceive('where')->with('bar', 1)
192197
->shouldReceive('getBindings')->andReturn(['simple', 'foo', 1]);
193198

194-
$db->shouldReceive('select')->with(null, $table->getBindings());
199+
$db->shouldReceive('select')->with(null, $table->getBindings())->once();
195200

196201
$builder = new Builder(new TestModel, 'foo');
197202
$builder->where('bar', 1)->take(5);
@@ -215,7 +220,7 @@ public function search_with_model_config()
215220
->shouldReceive('where')->with('bar', 1)
216221
->shouldReceive('getBindings')->andReturn(['english', 'foo', 1]);
217222

218-
$db->shouldReceive('select')->with(null, $table->getBindings());
223+
$db->shouldReceive('select')->with(null, $table->getBindings())->once();
219224

220225
$model = new TestModel;
221226
$model->searchableOptions['config'] = 'english';
@@ -241,7 +246,7 @@ public function search_with_soft_deletes()
241246
->shouldReceive('whereNull')->with('deleted_at')
242247
->shouldReceive('getBindings')->andReturn([null, 'foo', 1]);
243248

244-
$db->shouldReceive('select')->with(null, $table->getBindings());
249+
$db->shouldReceive('select')->with(null, $table->getBindings())->once();
245250

246251
$builder = new Builder(new SoftDeletableTestModel, 'foo');
247252
$builder->where('bar', 1)->take(5);

0 commit comments

Comments
 (0)