/** * @test */ public function shouldOrderEagerlyFetchedRelation() { //given $category = Category::where(array('name' => 'sony'))->fetch(); //when $products = $category->products_ordered_by_name; //then Assert::thatArray($products)->onProperty('name')->containsExactly('a', 'b', 'c'); }
/** * @test */ public function shouldSearchAnyOfWithRestrictions() { //given $category1 = Category::create(array('name' => 'test1')); $category2 = Category::create(array('name' => 'test2')); $category3 = Category::create(array('name' => 'other name')); Category::create(array('name' => 'some other name')); //when $categories = Category::where(Any::of(array('name' => Restrictions::like('tes%'), 'id' => $category3->getId())))->fetchAll(); //then Assert::thatArray($categories)->hasSize(3)->onProperty('name')->containsExactly($category1->name, $category2->name, $category3->name); }
/** * @test */ public function shouldFetchHasOneWithStringCondition() { //when $searchCategory = Category::where()->with('product_named_billy')->fetch(); //then $product = self::getNoLazy($searchCategory, 'product_named_billy'); $this->assertEquals('billy', $product->name); }