Annotation of embedaddon/php/ext/phar/tests/tar/phar_stub_error.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Phar::setStub()/getStub() tar-based
                      3: --SKIPIF--
                      4: <?php if (!extension_loaded("phar")) die("skip"); ?>
                      5: --INI--
                      6: phar.require_hash=0
                      7: phar.readonly=0
                      8: --FILE--
                      9: <?php
                     10: 
                     11: $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
                     12: 
                     13: $phar = new Phar($fname);
                     14: $stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>' ."\r\n";
                     15: $phar->setStub($stub);
                     16: $phar->setAlias('hio');
                     17: $phar['a'] = 'a';
                     18: $phar->stopBuffering();
                     19: 
                     20: var_dump($phar->getStub());
                     21: var_dump($phar->getStub() == $stub);
                     22: 
                     23: $newstub = '<?php echo "second stub\n"; _x_HALT_COMPILER(); ?>';
                     24: 
                     25: try {
                     26:        $phar->setStub($newstub);
                     27: } catch(exception $e) {
                     28:        echo 'Exception: ' . $e->getMessage() . "\n";
                     29: }
                     30: 
                     31: var_dump($phar->getStub());
                     32: var_dump($phar->getStub() == $stub);
                     33: $phar->stopBuffering();
                     34: var_dump($phar->getStub());
                     35: var_dump($phar->getStub() == $stub);
                     36: 
                     37: ?>
                     38: ===DONE===
                     39: --CLEAN--
                     40: <?php 
                     41: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
                     42: __HALT_COMPILER();
                     43: ?>
                     44: --EXPECTF--
                     45: string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
                     46: "
                     47: bool(true)
                     48: Exception: illegal stub for tar-based phar "%sphar_stub_error.phar.tar"
                     49: string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
                     50: "
                     51: bool(true)
                     52: string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
                     53: "
                     54: bool(true)
                     55: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>