/** * @group ZF2-337 */ public function testSettingNewStrictMode() { $validator = new InArray(array('haystack' => array('test', 0, 'A'))); $validator->setStrict(true); $this->assertTrue($validator->getStrict()); $this->assertFalse($validator->isValid('b')); $this->assertFalse($validator->isValid('a')); $this->assertTrue($validator->isValid('A')); $this->assertFalse($validator->isValid('0')); $this->assertTrue($validator->isValid(0)); }
public function testSettingNewStrictMode() { $validator = new Validator\InArray(array(1, 2, 3)); $this->assertFalse($validator->getStrict()); $this->assertTrue($validator->isValid('1')); $this->assertTrue($validator->isValid(1)); $validator->setStrict(true); $this->assertTrue($validator->getStrict()); $this->assertFalse($validator->isValid('1')); $this->assertTrue($validator->isValid(1)); }
public function testFloatStringInputAgainstNumberInHaystack() { $validator = new InArray(array('haystack' => array(1.5, 2.4))); $validator->setStrict(InArray::COMPARE_NOT_STRICT_AND_PREVENT_STR_TO_INT_VULNERABILITY); $this->assertFalse($validator->isValid('1.5asdf')); $validator->setStrict(InArray::COMPARE_NOT_STRICT); $this->assertTrue($validator->isValid('1.5asdf')); $validator->setStrict(InArray::COMPARE_STRICT); $this->assertFalse($validator->isValid('1.5asdf')); }