public function testCount()
 {
     list($conn, $query) = $this->getMocks();
     $instance = new CategoryItemRepository($conn);
     $mockItemEntity = m::mock('Xpressengine\\Category\\CategoryItemEntity');
     $mockItemEntity->id = 2;
     $conn->shouldReceive('table')->andReturn($query);
     $query->shouldReceive('leftJoin')->andReturnSelf();
     $query->shouldReceive('where')->once()->with(m::on(function () {
         return true;
     }), 2)->andReturnSelf();
     $query->shouldReceive('where')->once()->with(m::on(function () {
         return true;
     }), '<=', 1)->andReturnSelf();
     $query->shouldReceive('where')->once()->with(m::on(function () {
         return true;
     }), '!=', 0)->andReturnSelf();
     $query->shouldReceive('count')->once()->andReturn(3);
     $count = $instance->count($mockItemEntity, 1);
     $this->assertEquals(3, $count);
 }
 /**
  * Get an item's descendant count
  *
  * @param CategoryItemEntity $top   std item object for counting
  * @param int                $depth search depth value
  * @return int
  */
 public function count(CategoryItemEntity $top, $depth = 0)
 {
     return $this->itemRepo->count($top, $depth);
 }