public function testGetStringifiedData()
 {
     $i = new I();
     $i->iMember = 'a';
     $k = new K();
     $k->kMember = 'kA1';
     $i->ks->add($k);
     $this->assertTrue($i->save());
     $content = $i->ks->getStringifiedData();
     $this->assertEquals(array('kA1'), $content);
     $iId = $i->id;
     $i->forget();
     unset($i);
     $i = I::getById($iId);
     $content = $i->ks->getStringifiedData();
     $this->assertEquals(array('kA1'), $content);
     $k = new K();
     $k->kMember = 'kA2';
     $i->ks->add($k);
     $k = new K();
     $k->kMember = 'kA3';
     $i->ks->add($k);
     $this->assertTrue($i->save());
     $content = $i->ks->getStringifiedData();
     $this->assertEquals(array('kA1', 'kA2', 'kA3'), $content);
 }
 public function testChangingBelongsToSideOfHasManyRelation()
 {
     $k1 = new K();
     $k2 = new K();
     $i = new I();
     $i->ks->add($k1);
     $i->ks->add($k2);
     $this->assertTrue($i->save());
     $this->assertEquals(2, $i->ks->count());
     $k1->i = null;
     $this->assertTrue($k1->save());
     $iId = $i->id;
     $i->forget();
     unset($i);
     $i = I::getById($iId);
     $this->assertEquals(1, $i->ks->count());
     $i->ks->removeByIndex(0);
     $this->assertTrue($i->save());
     $this->assertEquals(0, $i->ks->count());
     $k2Id = $k2->id;
     $k2->forget();
     unset($k2);
     $k2 = K::getById($k2Id);
     $this->assertTrue($k2->i->id < 0);
 }