Exemple #1
0
 public function testRoles()
 {
     /*
     |------------------------------------------------------------
     | Set
     |------------------------------------------------------------
     */
     $belongsToMany = new stdClass();
     $user = m::mock('HasRoleUser')->makePartial();
     $app = m::mock('app')->shouldReceive('instance')->getMock();
     $config = m::mock('config');
     Config::setFacadeApplication($app);
     Config::swap($config);
     /*
     |------------------------------------------------------------
     | Expectation
     |------------------------------------------------------------
     */
     $user->shouldReceive('belongsToMany')->with('role_table_name', 'assigned_roles_table_name', 'user_id', 'role_id')->andReturn($belongsToMany)->once();
     Config::shouldReceive('get')->once()->with('entrust.role')->andReturn('role_table_name');
     Config::shouldReceive('get')->once()->with('entrust.role_user_table')->andReturn('assigned_roles_table_name');
     /*
     |------------------------------------------------------------
     | Assertion
     |------------------------------------------------------------
     */
     $this->assertSame($belongsToMany, $user->roles());
 }
 /**
  * Set up the tests
  */
 public function setUp()
 {
     parent::setUp();
     // Bind Polyglot classes
     $provider = new PolyglotServiceProvider($this->app);
     $provider->register();
     $provider->boot();
     $this->app['translator'] = $this->app['polyglot.translator'];
     // Configure facades
     Config::setFacadeApplication($this->app);
 }
 public function setUp()
 {
     parent::setUp();
     $app = m::mock('app')->shouldReceive('instance')->getMock();
     $this->facadeMocks['config'] = m::mock('config');
     $this->facadeMocks['cache'] = m::mock('cache');
     Config::setFacadeApplication($app);
     Config::swap($this->facadeMocks['config']);
     Cache::setFacadeApplication($app);
     Cache::swap($this->facadeMocks['cache']);
 }