コード例 #1
0
 /**
  * Store a newly created group in storage.
  */
 public function store()
 {
     $input = array('name' => Input::get('name'), 'permissions' => Input::get('permissions', array()));
     if ($this->groups->create($input)) {
         return Redirect::route('groups.index');
     }
     return Redirect::route('groups.create')->withErrors(array('name' => $this->groups->getError()))->withInput();
 }
コード例 #2
0
 public function testCreate()
 {
     Sentry::shouldReceive('createGroup')->once()->andThrow('Cartalyst\\Sentry\\Groups\\NameRequiredException');
     $this->assertFalse($this->groups->create(array()));
     Sentry::shouldReceive('createGroup')->once()->with(array('name' => 'Admin'))->andThrow('Cartalyst\\Sentry\\Groups\\GroupExistsException');
     $this->assertFalse($this->groups->create(array('name' => 'Admin')));
     $this->assertNotNull($this->groups->getError());
     Sentry::shouldReceive('createGroup')->once()->with(m::hasKey('name'))->andReturn(true);
     $this->assertTrue($this->groups->create(array('name' => '')));
     $this->assertNotNull($this->groups->getError());
 }