Phalcon\Test\Unit\Mvc\ModelTest::testInvalidVirtualForeignKeys PHP Method

testInvalidVirtualForeignKeys() public method

When having multiple virtual foreign keys, check of the first one should affect the check of the next one.
Since: 2016-08-03
Author: Radek Crlik ([email protected])
    public function testInvalidVirtualForeignKeys()
    {
        $this->specify('The Model::save with multiple virtual foreign keys and invalid entity', function () {
            $body = new Body();
            $body->head_1_id = null;
            $body->head_2_id = 999;
            // PDOException should'n be thrown
            expect($body->save())->equals(false);
            expect($body->getMessages())->count(1);
            expect($body->getMessages()[0]->getMessage())->equals('Second head does not exists');
        });
    }