Exemplo n.º 1
0
 public function testPrefixOnAutoTableNameWithTableSpecified()
 {
     Model::$auto_prefix_models = 'MockPrefix_';
     Model::factory('TableSpecified')->find_many();
     $expected = 'SELECT * FROM `simple`';
     $this->assertEquals($expected, ORM::get_last_query());
 }
Exemplo n.º 2
0
 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());
 }
Exemplo n.º 3
0
 public function testLazyLoading()
 {
     $owner = Model::factory('Owner')->find_one(1);
     $this->assertEquals($owner->car->manufactor_id, 1);
 }
Exemplo n.º 4
0
 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');
 }
Exemplo n.º 5
-1
 public function testCustomConnectionName()
 {
     $person3 = Model::factory('ModelWithCustomConnection')->find_one(1);
     $statement = ORM::get_last_statement();
     $this->assertInstanceOf('MockDifferentPDOStatement', $statement);
 }