Sokil\Mongo\DocumentValidationTest::testIsValid_FieldLength_Is PHP Method

testIsValid_FieldLength_Is() public method

    public function testIsValid_FieldLength_Is()
    {
        // mock of document
        $document = $this->getMock('\\Sokil\\Mongo\\Document', array('rules'), array($this->collection));
        $document->expects($this->any())->method('rules')->will($this->returnValue(array(array('some-field-name', 'length', 'is' => 5))));
        // required field empty
        $this->assertTrue($document->isValid());
        // required field set to wrong value
        $document->set('some-field-name', '1234567');
        $this->assertFalse($document->isValid());
        $this->assertEquals(array('some-field-name' => array('length' => 'Field "some-field-name" length not equal to 5 in model Sokil\\Mongo\\Validator\\LengthValidator')), $document->getErrors());
        // required field set to valid value
        $document->set('some-field-name', '12345');
        $this->assertTrue($document->isValid());
    }