/** * Will test the build of the more comples many-to-many and the case where there is more than one relationships. */ public function testComplexBuild() { self::reset(); fFixture::setDatabase(fORMDatabase::retrieve()); $fixture = fFixture::create(FIXTURES_ROOT); // includes: categories.json, products.json, users.json, shops.json and the join table categories_products.json $fixture->build(); $shop = new Shop(1); $user = new User(1); $category = new Category(1); $product = new Product(1); $this->assertTrue($shop->exists()); $this->assertTrue($user->exists()); $this->assertTrue($category->exists()); $this->assertTrue($product->exists()); // Shop has manu users and products $this->assertEquals(1, $shop->buildUsers()->count()); $this->assertEquals(1, $shop->buildProducts()->count()); // User and product has a shop $this->assertTrue($user->createShop()->exists()); $this->assertTrue($product->createShop()->exists()); // Product and category has many of eachother $this->assertEquals(1, $product->buildCategories()->count()); $this->assertEquals(1, $category->buildProducts()->count()); }