Sample usage:
Assert::thatModel(new User(['name' => 'bob']))->hasSameAttributesAs(new User(['name' => 'bob']));
public static thatModel ( |
||
$actual | ||
리턴 |
/** * @test */ public function shouldPassIfModelsAreEqual() { //given $product = new Product(array('name' => 'abc')); //when $otherProduct = new Product(array('name' => 'abc')); //then Assert::thatModel($product)->isEqualTo($otherProduct); }
public function assertAssignsModel($variable, $modelObject) { $modelVariable = $this->requestContext()->getCurrentControllerObject()->view->{$variable}; $this->assertNotNull($modelVariable); Assert::thatModel($modelVariable)->hasSameAttributesAs($modelObject); }
/** * @test */ public function shouldSearchForNullValue() { //given $category = Category::create(array('name' => 'shop')); $product = Product::create(array('name' => 'notebook', 'id_category' => $category->getId())); //when $search = Product::where(array('description' => null))->fetch(); //then Assert::thatModel($search)->isEqualTo($product); }
/** * @group non-sqlite3 * @test */ public function shouldReturnModelUsingRegexpRestriction() { //given $product = Product::create(array('name' => 'name1', 'description' => 'desc')); Product::create(array('name' => 'other product', 'description' => 'desc')); //when $loadedProduct = Product::where(array('name' => Restrictions::regexp('ame')))->fetch(); //then Assert::thatModel($loadedProduct)->isEqualTo($product); }