set() public méthode

Set taggable's tags
public set ( string $taggableId, array $words, string | null $instanceId = null ) : Illuminate\Database\Eloquent\Collection
$taggableId string taggable id
$words array tag word
$instanceId string | null instance id of taggable
Résultat Illuminate\Database\Eloquent\Collection model collection
 public function testSet()
 {
     list($repo, $decomposer) = $this->getMocks();
     $instance = new TagHandler($repo, $decomposer);
     $entity1 = m::mock('Xpressengine\\Tag\\TagEntity');
     $entity1->id = 1;
     $entity2 = m::mock('Xpressengine\\Tag\\TagEntity');
     $entity2->id = 2;
     $entity3 = m::mock('Xpressengine\\Tag\\TagEntity');
     $entity3->id = 3;
     $entity4 = m::mock('Xpressengine\\Tag\\TagEntity');
     $entity4->id = 4;
     $repo->shouldReceive('hasMany')->once()->with('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')->andReturn([$entity1, $entity2]);
     $repo->shouldReceive('findByInstanceIdAndWord')->once()->with('freeboard', 'laravel')->andReturnNull();
     $repo->shouldReceive('findByInstanceIdAndWord')->once()->with('freeboard', 'cms')->andReturnNull();
     $repo->shouldReceive('findByInstanceIdAndWord')->once()->with('freeboard', 'xpressengine')->andReturn($entity1);
     $decomposer->shouldReceive('execute')->once()->with('laravel')->andReturn('laravel');
     $decomposer->shouldReceive('execute')->once()->with('cms')->andReturn('cms');
     $repo->shouldReceive('insert')->once()->withAnyArgs()->andReturn($entity3);
     $repo->shouldReceive('insert')->once()->withAnyArgs()->andReturn($entity4);
     $repo->shouldReceive('existsUsed')->once()->with('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', $entity3)->andReturn(false);
     $repo->shouldReceive('insertUsed')->once()->with('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', $entity3)->andReturnNull();
     $repo->shouldReceive('increment')->once()->with($entity3)->andReturnNull();
     $repo->shouldReceive('existsUsed')->once()->with('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', $entity4)->andReturn(false);
     $repo->shouldReceive('insertUsed')->once()->with('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', $entity4)->andReturnNull();
     $repo->shouldReceive('increment')->once()->with($entity4)->andReturnNull();
     $repo->shouldReceive('existsUsed')->once()->with('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', $entity1)->andReturn(true);
     $repo->shouldReceive('existsUsed')->once()->with('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', $entity2)->andReturn(true);
     $repo->shouldReceive('deleteUsed')->once()->with('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', $entity2)->andReturnNull();
     $repo->shouldReceive('decrement')->once()->with($entity2)->andReturnNull();
     $instance->set('freeboard', 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', ['laravel', 'cms', 'xpressengine']);
 }
 /**
  * set tags
  *
  * @param Board $board board model
  * @param array $args  arguments
  * @return void
  */
 protected function setTags(Board $board, array $args)
 {
     if (empty($args['_hashTags']) === false) {
         $this->tag->set($board->getKey(), $args['_hashTags']);
     }
 }