public function testValidation() { $user = new User(); $user->password = '******'; $this->assertFalse($user->hasErrors()); $this->assertEquals(array(), $user->errors); $this->assertEquals(array(), $user->getErrors('username')); $this->assertFalse($user->save()); $this->assertNull($user->id); $this->assertTrue($user->isNewRecord); $this->assertTrue($user->hasErrors()); $this->assertTrue($user->hasErrors('username')); $this->assertTrue($user->hasErrors('email')); $this->assertFalse($user->hasErrors('password')); $this->assertEquals(1, count($user->getErrors('username'))); $this->assertEquals(1, count($user->getErrors('email'))); $this->assertEquals(2, count($user->errors)); $user->clearErrors(); $this->assertFalse($user->hasErrors()); $this->assertEquals(array(), $user->errors); }