public function testReadInvalid() { $collector = new EarthIT_Collector(); $parser = new TOGoS_PNGChunks_Parser($collector, array(TOGoS_PNGChunks_Parser::OPT_VALIDATE => true)); $caught = false; try { $parser->data("ASDF!@#\$"); } catch (TOGoS_PNGChunks_MalformedDataException $e) { $caught = true; } $this->assertTrue($caught, "Should have thrown a MalformedDataException"); }
public function testRead() { $testPngData = file_get_contents('test/pnggrad8rgb.png'); if ($testPngData === false) { throw new Exception("Failed to open test PNG file."); } $collector = new EarthIT_Collector(); $parser = new TOGoS_PNGChunks_Parser($collector, array(TOGoS_PNGChunks_Parser::OPT_VALIDATE => true)); $parser->data($testPngData); $parser->end(); $readChunks = $collector->collection; $rewrittenBlob = new TOGoS_PNGChunks_PNGBlob($readChunks); $this->assertEquals($testPngData, (string) $rewrittenBlob); }