Neos\Flow\Tests\Functional\Validation\Validator\UniqueEntityValidatorTest::validatorBehavesCorrectlyOnDuplicateEntityWithSingleConfiguredIdentityProperty PHP Метод

validatorBehavesCorrectlyOnDuplicateEntityWithSingleConfiguredIdentityProperty() публичный Метод

    public function validatorBehavesCorrectlyOnDuplicateEntityWithSingleConfiguredIdentityProperty()
    {
        $validator = new \Neos\Flow\Validation\Validator\UniqueEntityValidator(['identityProperties' => ['title']]);
        $post = new Post();
        $post->setTitle('The title of the initial post');
        $this->postRepository->add($post);
        $this->persistenceManager->persistAll();
        $this->persistenceManager->clearState();
        $differentPost = new Post();
        $differentPost->setTitle('A different title');
        $this->assertFalse($validator->validate($differentPost)->hasErrors());
        $nextPost = new Post();
        $nextPost->setTitle('The title of the initial post');
        $this->assertTrue($validator->validate($nextPost)->hasErrors());
    }