Example #1
0
 public function no_testLoadRelationManyMany()
 {
     $users = array(new User(), new User());
     $qb = $this->getMock('\\SimpleAR\\Orm\\Builder', array('all'));
     $qb->expects($this->once())->method('all')->will($this->returnValue($users));
     Article::setQueryBuilder($qb);
     $article = new Article();
     $article->populate(array('id' => 12));
     // In order to be concrete.
     $article->load('readers');
     $attributes = $article->attributes();
     $this->assertArrayHasKey('readers', $attributes);
     $this->assertEquals($users, $attributes['readers']);
     $relation = Article::relation('readers');
     $reversed = User::relation('readers_r');
     $this->assertInstanceOf('SimpleAR\\Orm\\Relation\\ManyMany', $reversed);
     $this->assertEquals($relation->reverse(), $reversed);
 }