public function testPrefixOnAutoTableNameWithTableSpecified() { Model::$auto_prefix_models = 'MockPrefix_'; Model::factory('TableSpecified')->find_many(); $expected = 'SELECT * FROM `simple`'; $this->assertEquals($expected, ORM::get_last_query()); }
public function testHasManyThroughRelationWithCustomIntermediateModelAndKeyNames() { $book2 = Model::factory('BookTwo')->find_one(1); $authors2 = $book2->authors()->find_many(); $expected = "SELECT `author`.* FROM `author` JOIN `author_book` ON `author`.`id` = `author_book`.`custom_author_id` WHERE `author_book`.`custom_book_id` = '1'"; $this->assertEquals($expected, ORM::get_last_query()); }
public function testLazyLoading() { $owner = Model::factory('Owner')->find_one(1); $this->assertEquals($owner->car->manufactor_id, 1); }
public function testCallStaticForModel() { $expected = Model::factory('Car')->with('manufactor')->find_one(1); $car = Car::with('manufactor')->find_one(1); $this->assertEquals($expected, $car, 'Call from static and from factory are the same'); }
public function testCustomConnectionName() { $person3 = Model::factory('ModelWithCustomConnection')->find_one(1); $statement = ORM::get_last_statement(); $this->assertInstanceOf('MockDifferentPDOStatement', $statement); }