예제 #1
0
 public function testLoadingRelations()
 {
     $this->specify("eager loading is applied when only one is given", function () {
         $this->assertCount(1, TestModel::pimp(['a' => 'b'], ['sort' => 'field1,asc'], 'relation1')->getEagerLoads());
         $this->assertContains('relation1', array_keys(TestModel::pimp(['a' => 'b'], ['sort' => 'field1,asc'], 'relation1')->getEagerLoads()));
         $this->assertNotContains('relation2', array_keys(TestModel::pimp(['a' => 'b'], ['sort' => 'field1,asc'], 'relation1')->getEagerLoads()));
     });
     $this->specify("eager loading are applied when array is given", function () {
         $this->assertCount(2, TestModel::pimp(['a' => 'b'], ['sort' => 'field1,asc'], ['relation1', 'relation2'])->getEagerLoads());
         $this->assertContains('relation1', array_keys(TestModel::pimp(['a' => 'b'], ['sort' => 'field1,asc'], ['relation1', 'relation2'])->getEagerLoads()));
         $this->assertContains('relation2', array_keys(TestModel::pimp(['a' => 'b'], ['sort' => 'field1,asc'], ['relation1', 'relation2'])->getEagerLoads()));
         $this->assertNotContains('relation3', array_keys(TestModel::pimp(['a' => 'b'], ['sort' => 'field1,asc'], ['relation1', 'relation2'])->getEagerLoads()));
     });
 }