Example #1
0
 public function testInRole()
 {
     $user = new EloquentUser();
     $user->setConnectionResolver($resolver = m::mock('Illuminate\\Database\\ConnectionResolverInterface'));
     $resolver->shouldReceive('connection')->andReturn(m::mock('Illuminate\\Database\\Connection'));
     $user->getConnection()->shouldReceive('getQueryGrammar')->andReturn(m::mock('Illuminate\\Database\\Query\\Grammars\\Grammar'));
     $user->getConnection()->shouldReceive('getPostProcessor')->andReturn($processor = m::mock('Illuminate\\Database\\Query\\Processors\\Processor'));
     $user->getConnection()->getQueryGrammar()->shouldReceive('getDateFormat')->andReturn('Y-m-d H:i:s');
     $user->getConnection()->getQueryGrammar()->shouldReceive('compileInsertGetId');
     $processor->shouldReceive('processSelect')->andReturn([['slug' => 'foobar'], ['slug' => 'foo'], ['slug' => 'bar']]);
     $user->getConnection()->getQueryGrammar()->shouldReceive('compileSelect');
     $user->getConnection()->shouldReceive('select');
     $this->assertTrue($user->inRole('foobar'));
     $this->assertTrue($user->inRole('foo'));
     $this->assertTrue($user->inRole('bar'));
     $this->assertFalse($user->inRole('baz'));
 }