Sokil\Mongo\DocumentEventTest::testOnValidateError PHP Method

testOnValidateError() public method

public testOnValidateError ( )
    public function testOnValidateError()
    {
        $documentMock = $this->getMock('\\Sokil\\Mongo\\Document', array('rules'), array($this->collection, array('e' => 'wrongEmail')));
        $documentMock->expects($this->once())->method('rules')->will($this->returnValue(array(array('e', 'email', 'mx' => false))));
        $documentMock->onValidateError(function ($e) {
            $e->getTarget()->status = 'error';
        });
        try {
            $documentMock->validate();
            $this->fail('Must be validate exception');
        } catch (\Sokil\Mongo\Document\InvalidDocumentException $e) {
            $this->assertEquals('error', $documentMock->status);
        }
    }