Sokil\Mongo\DocumentEventTest::testCancelOperation_BeforeValidate PHP Метод

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

    public function testCancelOperation_BeforeValidate()
    {
        $testCase = $this;
        $this->collection->createDocument()->onBeforeValidate(function (\Sokil\Mongo\Event $event, $eventName, $dispatcher) {
            $event->cancel();
        })->onAfterValidate(function (\Sokil\Mongo\Event $event, $eventName, $dispatcher) use($testCase) {
            $testCase->fail('Validation must be cancelled');
        })->validate();
    }