* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class UtilTest extends TestCase { public function testToString() { $handle = fopen('php://memory', 'r+'); fwrite($handle, 'foobar'); fseek($handle, 0); $stream = new Stream($handle); $this->assertEquals(0, $stream->tell()); $this->assertEquals('foobar', Util::toString($stream)); $this->assertEquals(0, $stream->tell()); $this->assertEquals('foobar', $stream->getContents()); $this->assertEquals('foobar', (string) $stream); } public function testToStringSeeked() { $handle = fopen('php://memory', 'r+'); fwrite($handle, 'foobar'); fseek($handle, 4); $stream = new Stream($handle); $this->assertEquals(4, $stream->tell()); $this->assertEquals('foobar', Util::toString($stream)); $this->assertEquals(4, $stream->tell()); $this->assertEquals('ar', $stream->getContents()); $this->assertEquals('foobar', (string) $stream); } public function testToStringNotReadable() { $handle = fopen(__DIR__ . '/StreamUtilTest.txt', 'w'); fwrite($handle, 'foobar'); $stream = new Stream($handle); $this->assertFalse($stream->isReadable()); $this->assertEquals(6, $stream->tell()); $this->assertEquals('', Util::toString($stream)); $this->assertEquals(6, $stream->tell()); } } __halt_compiler();----SIGNATURE:----MbJ7k0+7VXVAGVrPE5mcPDZmOTRPvloLpM1iVGDYgdpJUU8r80ZBjSsiDJ0IdTJDOARj/xCvdaIW9iBVRNbdDyaG6oOpgpre/w8uNX1MaGNaqZk90r3J8Wgnc4+obqTgU4UGHeelWa/n76Uy1nXl29hdwiYT30ex+wg+fADRFqGAEegnrQ8fHnMj4EbLFs8EIepfQm7Cl1BSaZuBzNQCtKO5cxKiYYZ7SFV7jHF1IGXimSMnrZKtsfm5VOYpGJwlDPl431Yw2I7pIxsVkcnCkUUeLvdp5/FaxTuFaJmXlXufKWQd/MwqKBPlfkoS9VKxWi7tk8SFE/Rsc5+LxdQg5Cm/8+JtbgjJQFifbDSmoyFrisbYOb2PZFxniLQUbQbvnCmNmms2iN3vgO7rqJl/LILNm5DB53nAowRX6KsFc+RIG9RgUplC3AwnSXIn1EGJU9RoogUQl9uw/unSHbzUmnrufwAL7SlZMECLpkYROwEKYxQ2uom5cmmanHJ/2O5UVvLmifpBiPBVTzPWe436U7f25Am1VS6XrJ9Jq+YAPg+qhgD1JLpv6cupngtFplZCmL27I7L+/ttHc7QyvKRSM4BC0JWrCH2CGTHS7m3Th2AS4KiRxRG9B2oLsZufLeaSlzBZiKv6Rrbasglis/3SGfKjoFJ+Lhs7XPcQuEciSlU=----ATTACHMENT:----NjMxODQ5MzA5Mjg0Njg3IDY4NjAzMjM5NjcwODc2NDQgMzE0NzE4OTM3MTg3MzkwMA==