public function testSaveMixedRelationsShouldSucceed() { $project = new Project(); $project->name = "New project"; $project->company = Company::findOne(2); $users = User::findAll([1, 3]); $this->assertCount(0, $project->users, 'Project should have 0 users before save'); $project->users = $users; // Add users $this->assertEquals(2, count($project->users), 'Project should have 2 users after assignment'); $this->assertTrue($project->save(), 'Project could not be saved'); $this->assertCount(2, $project->users, 'Project should have 2 users after save'); $this->assertEquals(2, $project->company_id, 'Company ID is not the one expected'); }
/** * method that test if the system found all records * @expectedException \yii\base\Exception */ public function testFindAll() { User::findAll([]); }