示例#1
0
 /**
  * @test
  */
 public function shouldAliasTables()
 {
     //given
     $category = Category::create(array('name' => 'phones'));
     Product::create(array('name' => 'a', 'id_category' => $category->getId()));
     //when
     $product = Product::alias('p')->join('category', 'c')->where("p.name = 'a' and c.name = 'phones'")->fetch();
     //then
     $this->assertNotNull($product);
     $this->assertEquals($category, self::getNoLazy($product, 'category'));
     Assert::thatArray($product->attributes())->containsKeyAndValue(array('name' => 'a', 'id_category' => $category->getId()));
 }