Suffix = '.rs'; $this->Image = 'header'; $this->TestFormat = 'jpg'; //$this->Netpbm = new Netpbm(NETPBM_PATH, dirname(__FILE__)); $this->Netpbm = new NetpbmResize('C:\\web\\elportondelagarza\\admin\\bin', dirname(__FILE__)); copy('test.gif', 'header.gif'); copy('test.jpg', 'header.jpg'); copy('test.png', 'header.png'); } function tearDown() { /* unlink('header.gif'); unlink('header.jpg'); unlink('header.png'); */ } function testInitializing() { $this->assertIsA($this->Netpbm, NetpbmResize); } function testResize() { foreach ($this->imgs as $format) { $this->Netpbm->resize(200, $this->Image . '.' . $format); $size = getimagesize($this->Image . $this->Suffix . '.' . $format); $result = false; if ($size[1] == 200 or $size[0] == 200) { $result = true; } $this->assertTrue($result); } } function testResizeByHeight() { $this->Netpbm->resizeByHeight(200, $this->Image . '.' . $this->TestFormat); $size = getimagesize($this->Image . $this->Suffix . '.' . $this->TestFormat); $this->assertEqual(200, $size[1]); } function testResizeByWidth() { $this->Netpbm->resizeByWidth(200, $this->Image . '.' . $this->TestFormat); $size = getimagesize($this->Image . $this->Suffix . '.' . $this->TestFormat); $this->assertEqual(200, $size[0]); } function testResizeByPercentage() { $prev = getimagesize($this->Image . '.' . $this->TestFormat); clearstatcache(); $percent = .3; $this->Netpbm->setOutputImage('mycustom'); $this->Netpbm->resizeByPercentage($percent, $this->Image . '.' . $this->TestFormat); $size = getimagesize('mycustom.' . $this->TestFormat); //echo $size[1], $prev[1]; $test = intval($prev[1] * $percent); $this->assertEqual($size[1], $test); } function testSquareThumbnail() { $n = new NetpbmResize('C:\\web\\elportondelagarza\\admin\\bin', $this->Image . '.gif'); $n->resize(100, $this->Image . '.png'); $suffix = '_st'; $n->squareThumbnail(75, $suffix); $this->assertTrue(file_exists($this->Image . $suffix . '.png')); } function testMultiResize() { $n = new NetpbmResize('C:\\web\\elportondelagarza\\admin\\bin', dirname(__FILE__)); $sizes = array(100 => '_t', 200 => '_s', 300 => '_m'); $n->resize($sizes, $this->Image . '.jpg'); $n->squareThumbnail(100); foreach ($sizes as $expected => $suffix) { $dim = getimagesize($this->Image . $suffix . '.jpg'); $result = false; if ($dim[1] == $expected or $dim[0] == $expected) { $result = true; } $this->assertTrue($result); } } } $test = &new TestOfNetpbm('Testing NetpbmResize >.>'); $test->run(new HtmlReporter()); ?>