public function testFind()
 {
     list($conn, $query) = $this->getMocks();
     $instance = new CategoryRepository($conn);
     $conn->shouldReceive('table')->andReturn($query);
     $query->shouldReceive('where')->once()->with('id', 1)->andReturnSelf();
     $query->shouldReceive('first')->once()->andReturn(['id' => 1, 'name' => 'cate']);
     $category = $instance->find(1);
     $this->assertInstanceOf('Xpressengine\\Category\\CategoryEntity', $category);
     $this->assertEquals(1, $category->id);
     $this->assertEquals('cate', $category->name);
 }
Ejemplo n.º 2
0
 /**
  * Get a category
  *
  * @param int $id category id
  * @return null|CategoryEntity
  */
 public function get($id)
 {
     return $this->repo->find($id);
 }