public function testGetUser() { // Current user $user = m::mock('User'); $entrust = new Entrust($this->mockAppWithCurrentUser($user)); // Check the returned user $this->assertEquals($entrust->user(), $user); }
/** * Get the currently authenticated user or null. * * @return \Zizaco\Entrust\User|null * @static */ public static function user() { return \Zizaco\Entrust\Entrust::user(); }
public function testUser() { /* |------------------------------------------------------------ | Set |------------------------------------------------------------ */ $app = new stdClass(); $app->auth = m::mock('Auth'); $entrust = new Entrust($app); $user = m::mock('_mockedUser'); /* |------------------------------------------------------------ | Expectation |------------------------------------------------------------ */ $app->auth->shouldReceive('user')->andReturn($user)->once(); /* |------------------------------------------------------------ | Assertion |------------------------------------------------------------ */ $this->assertSame($user, $entrust->user()); }