/** * Ensures that setImageMax() returns expected value * * @return void */ public function testSetImageMax() { $validator = new File\ImageSize(array('minWidth' => 10, 'minHeight' => 100, 'maxWidth' => 1000, 'maxHeight' => 10000)); $validator->setImageMax(array('maxWidth' => 100, 'maxHeight' => 100)); $this->assertEquals(array('maxWidth' => 100, 'maxHeight' => 100), $validator->getImageMax()); $validator->setImageMax(array('maxWidth' => 110, 'maxHeight' => 1000)); $this->assertEquals(array('maxWidth' => 110, 'maxHeight' => 1000), $validator->getImageMax()); $validator->setImageMax(array('maxHeight' => 1100)); $this->assertEquals(array('maxWidth' => 110, 'maxHeight' => 1100), $validator->getImageMax()); $validator->setImageMax(array('maxWidth' => 120)); $this->assertEquals(array('maxWidth' => 120, 'maxHeight' => 1100), $validator->getImageMax()); $this->setExpectedException('Zend\\Validator\\Exception\\InvalidArgumentException', 'greater than or equal'); $validator->setImageMax(array('maxWidth' => 10000, 'maxHeight' => 1)); }
/** * Ensures that setImageMax() returns expected value * * @return void */ public function testSetImageMax() { $validator = new File\ImageSize(array('minwidth' => 10, 'minheight' => 100, 'maxwidth' => 1000, 'maxheight' => 10000)); $validator->setImageMax(array('maxwidth' => 100, 'maxheight' => 100)); $this->assertEquals(array('maxwidth' => 100, 'maxheight' => 100), $validator->getImageMax()); $validator->setImageMax(array('maxwidth' => 110, 'maxheight' => 1000)); $this->assertEquals(array('maxwidth' => 110, 'maxheight' => 1000), $validator->getImageMax()); $validator->setImageMax(array('maxheight' => 1100)); $this->assertEquals(array('maxwidth' => 110, 'maxheight' => 1100), $validator->getImageMax()); $validator->setImageMax(array('maxwidth' => 120)); $this->assertEquals(array('maxwidth' => 120, 'maxheight' => 1100), $validator->getImageMax()); try { $validator->setImageMax(array('maxwidth' => 10000, 'maxheight' => 1)); $this->fail("Missing exception"); } catch (Validator\Exception $e) { $this->assertContains("greater than or equal", $e->getMessage()); } }