public function testSelectWithEagerTwoSteps()
 {
     $this->loadData('bookshop');
     $this->resetQueryCount();
     $authors = Author::select($this->getConn())->with('books', function ($q) {
         $q->with('details');
     })->execute();
     //simulation of some application logic
     foreach ($authors as $author) {
         if (count($author->books) < 1 || !$author->books[0]->has('details')) {
             continue;
         }
         $author->books[0]->details->synposis;
     }
     $this->assertSame($authors[1]->books[0]->details->synopsis, 'Something something something');
     //only three queries: authors, books and details
     $this->assertSame(3, $this->getQueryCount());
 }
 public function testEventCallbacksAreClassSpecific()
 {
     Book::resetEventCallbacks();
     Author::resetEventCallbacks();
     $foo = function () {
     };
     $bar = function () {
     };
     Book::addEventCallBack('insert', $foo);
     Author::addEventCallBack('update', $bar);
     $callbacks = new \ReflectionProperty('ActiveDoctrine\\Entity\\Entity', 'callbacks');
     $callbacks->setAccessible(true);
     $this->assertSame(['insert' => [$foo]], $callbacks->getValue()['ActiveDoctrine\\Tests\\Fixtures\\Bookshop\\Book']);
     $this->assertSame(['update' => [$bar]], $callbacks->getValue()['ActiveDoctrine\\Tests\\Fixtures\\Bookshop\\Author']);
 }