create() public method

Create a new group.
public create ( $name ) : Model | static
$name
return Illuminate\Database\Eloquent\Model | static
Ejemplo n.º 1
0
 /**
  * Add a group in the db
  *
  * @param $name
  * @throws InvalidArgumentException
  * @return \Illuminate\Database\Eloquent\Model|static
  */
 public function addGroup($name)
 {
     if ($this->isStringWithDots($name)) {
         return $this->groupRepo->create($name);
     }
     $error = "The name must be a string with dots as namespaces";
     throw new InvalidArgumentException($error);
 }
Ejemplo n.º 2
0
 /** @test */
 function it_add_a_group_in_the_db_respecting_convention(NotifynderGroupDB $groupDB, NotificationGroup $group)
 {
     $name = 'my.category';
     $groupDB->create($name)->shouldBeCalled()->willReturn($group);
     $this->addGroup($name)->shouldReturnAnInstanceOf(NotificationGroup::class);
 }