/** * Setup the DB once, not before every test. */ public static function setUpBeforeClass() { Database::registry()->addDriver('default', new MongoDriver(Config::get('db'))); // Remove singletons User::flushInstances(); Book::flushInstances(); Series::flushInstances(); Profile::flushInstances(); }
public function testUpdateWithManyToOne() { $this->loadFixtures(['Series', 'Books']); $series = Series::find(1); $this->assertEquals(new Series(['id' => 1, 'author_id' => 1, 'name' => 'A Song of Ice and Fire']), $series); // Update a book $book = Book::find(1); $book->name = 'GOT'; $series->name = 'ASOIAF'; $book->link($series); $this->assertEquals(1, $book->save(['validate' => false])); $this->assertEquals(new Book(['id' => 1, 'series_id' => 1, 'name' => 'GOT', 'isbn' => '0-553-10354-7', 'released' => '1996-08-02', 'Series' => new Series(['id' => 1, 'author_id' => 1, 'name' => 'ASOIAF'])]), Book::select()->with('Series')->where('id', 1)->first()); }