상속: extends Pheasant\DomainObject
예제 #1
0
 public function testEmptyRelationshipsWithoutAllowEmpty()
 {
     $power = new Power(array('description' => 'Spider Senses'));
     $power->save();
     $this->setExpectedException('\\Pheasant\\Exception');
     $foo = $power->Hero;
 }
예제 #2
0
파일: Hero.php 프로젝트: lox/pheasant
 public static function createHelper($alias, $identity, $powers = array())
 {
     $hero = new Hero(array('alias' => $alias));
     $hero->save();
     $identity = new SecretIdentity(array('realname' => $identity));
     $hero->SecretIdentity = $identity;
     $identity->save();
     foreach ($powers as $power) {
         $power = new Power(array('description' => $power));
         $hero->Powers[] = $power;
         $power->save();
     }
     $hero->save();
     return $hero;
 }
예제 #3
0
파일: JoinTest.php 프로젝트: lox/pheasant
 public function testNestedJoiningAndFiltering()
 {
     $collection = Power::all()->join(array('Hero' => array('SecretIdentity' => array('Hero h2'))))->filter('SecretIdentity.realname = ?', "Peter Parker");
     $this->assertCount(2, $collection);
     $this->assertEquals('Super-human Strength', $collection[0]->description);
     $this->assertEquals('Spider Senses', $collection[1]->description);
 }
예제 #4
0
 public function testNestedIncludesHitsCache()
 {
     $queries = 0;
     $this->connection()->filterChain()->onQuery(function ($sql) use(&$queries) {
         ++$queries;
         return $sql;
     });
     // the first lookup of SecretIdentity should cache all the rest
     $powers = Power::all()->includes(array('Hero' => array('SecretIdentity')))->toArray();
     $this->assertNotNull($powers[0]->Hero->SecretIdentity);
     // these should be from cache
     $queries = 0;
     foreach ($powers as $power) {
         $this->assertNotNull($power->Hero->SecretIdentity);
     }
     $this->assertEquals(0, $queries, "this should have hit the cache");
 }