Annotation of embedaddon/php/ext/tokenizer/tests/token_get_all_basic.phpt, revision 1.1.1.2

1.1       misho       1: --TEST--
                      2: Test token_get_all() function : basic functionality 
1.1.1.2 ! misho       3: --SKIPIF--
        !             4: <?php if (!extension_loaded("tokenizer")) print "skip"; ?>
1.1       misho       5: --FILE--
                      6: <?php
                      7: /* Prototype  : array token_get_all(string $source)
                      8:  * Description : splits the given source into an array of PHP languange tokens
                      9:  * Source code: ext/tokenizer/tokenizer.c
                     10: */
                     11: 
                     12: echo "*** Testing token_get_all() : basic functionality ***\n";
                     13: 
                     14: // with php open/close tags
                     15: $source = '<?php echo "Hello World"; ?>';
                     16: echo "-- source string with PHP open and close tags --\n";
                     17: var_dump( token_get_all($source) );
                     18: 
                     19: // without php open/close tags testing for T_INLINE_HTML
                     20: $source = "echo 'Hello World';";
                     21: echo "-- source string without PHP open and close tags --\n";
                     22: var_dump( token_get_all($source) );
                     23: 
                     24: echo "Done"
                     25: ?>
                     26: --EXPECTF--
                     27: *** Testing token_get_all() : basic functionality ***
                     28: -- source string with PHP open and close tags --
                     29: array(7) {
                     30:   [0]=>
                     31:   array(3) {
                     32:     [0]=>
1.1.1.2 ! misho      33:     int(%d)
1.1       misho      34:     [1]=>
                     35:     string(6) "<?php "
                     36:     [2]=>
                     37:     int(1)
                     38:   }
                     39:   [1]=>
                     40:   array(3) {
                     41:     [0]=>
1.1.1.2 ! misho      42:     int(%d)
1.1       misho      43:     [1]=>
                     44:     string(4) "echo"
                     45:     [2]=>
                     46:     int(1)
                     47:   }
                     48:   [2]=>
                     49:   array(3) {
                     50:     [0]=>
1.1.1.2 ! misho      51:     int(%d)
1.1       misho      52:     [1]=>
                     53:     string(1) " "
                     54:     [2]=>
                     55:     int(1)
                     56:   }
                     57:   [3]=>
                     58:   array(3) {
                     59:     [0]=>
1.1.1.2 ! misho      60:     int(%d)
1.1       misho      61:     [1]=>
                     62:     string(13) ""Hello World""
                     63:     [2]=>
                     64:     int(1)
                     65:   }
                     66:   [4]=>
                     67:   string(1) ";"
                     68:   [5]=>
                     69:   array(3) {
                     70:     [0]=>
1.1.1.2 ! misho      71:     int(%d)
1.1       misho      72:     [1]=>
                     73:     string(1) " "
                     74:     [2]=>
                     75:     int(1)
                     76:   }
                     77:   [6]=>
                     78:   array(3) {
                     79:     [0]=>
1.1.1.2 ! misho      80:     int(%d)
1.1       misho      81:     [1]=>
                     82:     string(2) "?>"
                     83:     [2]=>
                     84:     int(1)
                     85:   }
                     86: }
                     87: -- source string without PHP open and close tags --
                     88: array(1) {
                     89:   [0]=>
                     90:   array(3) {
                     91:     [0]=>
1.1.1.2 ! misho      92:     int(%d)
1.1       misho      93:     [1]=>
                     94:     string(19) "echo 'Hello World';"
                     95:     [2]=>
                     96:     int(1)
                     97:   }
                     98: }
1.1.1.2 ! misho      99: Done

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