function testAddBeforeSave() { $nb_devels = SActiveStore::count('Developer'); $nb_projs = SActiveStore::count('Project'); $peter = new Developer(array('name' => 'peter')); $proj1 = new Project(array('name' => 'WebNuked2.0')); $proj2 = new Project(array('name' => 'TotalWebInnov')); $peter->projects[] = $proj1; $peter->projects[] = $proj2; $this->assertTrue($peter->isNewRecord()); $this->assertTrue($proj1->isNewRecord()); $peter->save(); $this->assertFalse($peter->isNewRecord()); $this->assertEqual($nb_devels + 1, SActiveStore::count('Developer')); $this->assertEqual($nb_projs + 2, SActiveStore::count('Project')); $this->assertEqual(2, $peter->countProjects()); $peter->projects(True); $this->assertEqual(2, $peter->countProjects()); }