Skip to content

Commit

Permalink
Add tests against strict taxanomy.
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Nov 3, 2019
1 parent f201509 commit 2ee26b6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/Unit/TaxonomyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,27 @@ public function it_can_build_match_query()
return $c($query);
}
})
->shouldReceive('when')->once()->with(true, m::type('Closure'))
->andReturnUsing(static function ($b, $c) use ($query) {
if (!! $b) {
return $c($query);
}
})
->shouldReceive('where')->once()->with('name', '=', 'hello')->andReturnSelf()
->shouldReceive('whereIn')->once()->with('roles', ['admin', 'staff'])->andReturnSelf();
->shouldReceive('whereIn')->once()->with('roles', ['admin', 'staff'])->andReturnSelf()
->shouldReceive('whereNotNull')->once()->with('deleted_at')->andReturnSelf();

$stub = new Taxonomy(
'name:hello role:admin role:staff', [
'name:hello role:admin role:staff is:active', [
'name:*' => static function ($query, $value) {
return $query->where('name', '=', $value);
},
'role:[]' => static function ($query, $value) {
return $query->whereIn('roles', $value);
},
'is:active' => static function ($query) {
return $query->whereNotNull('deleted_at');
},
], ['name']
);

Expand Down

0 comments on commit 2ee26b6

Please sign in to comment.