/**
  * Set a target unused category item
  *
  * @param string             $targetId target id
  * @param CategoryItemEntity $item     item object
  * @return void
  */
 public function unused($targetId, CategoryItemEntity $item)
 {
     if ($this->itemRepo->existsUsed($targetId, $item)) {
         $this->itemRepo->deleteUsed($targetId, $item);
         $item->count--;
         $this->itemRepo->update($item);
     }
 }
 public function testUpdate()
 {
     list($conn, $query) = $this->getMocks();
     $instance = new CategoryItemRepository($conn);
     $mockItemEntity = m::mock('Xpressengine\\Category\\CategoryItemEntity');
     $mockItemEntity->shouldReceive('diff')->andReturn(['word' => 'blar']);
     $mockItemEntity->shouldReceive('getOriginal')->andReturn(['id' => 2, 'categoryId' => 1, 'word' => 'blarblar']);
     $mockItemEntity->id = 2;
     $conn->shouldReceive('table')->andReturn($query);
     $query->shouldReceive('where')->once()->with('id', 2)->andReturnSelf();
     $query->shouldReceive('update')->once()->with(m::on(function ($array) {
         return $array['word'] === 'blar';
     }))->andReturnNull();
     $item = $instance->update($mockItemEntity);
     $this->assertEquals(2, $item->id);
     $this->assertEquals('blar', $item->word);
 }