Annotation of embedaddon/php/ext/spl/tests/countable_count_variation1.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: SPL: Countable::count() with wrong return types and exception.
                      3: --FILE--
                      4: <?php
                      5: 
                      6: Class returnNull implements Countable {
                      7:        function count() {
                      8:        }
                      9: }
                     10: 
                     11: Class returnString implements Countable {
                     12:        function count() {
                     13:                return "hello";
                     14:        }
                     15: }
                     16: 
                     17: Class returnObject implements Countable {
                     18:        function count() {
                     19:                return new returnObject;
                     20:        }
                     21: }
                     22: 
                     23: Class returnArray implements Countable {
                     24:        function count() {
                     25:                return array(1,2,3);
                     26:        }
                     27: }
                     28: 
                     29: Class throwException implements Countable {
                     30:        function count() {
                     31:                throw new Exception('Thrown from count');
                     32:        }
                     33: }
                     34: 
                     35: 
                     36: echo "Count returns null:\n";
                     37: var_dump(count(new returnNull));
                     38: 
                     39: echo "Count returns a string:\n";
                     40: var_dump(count(new returnString));
                     41: 
                     42: echo "Count returns an object:\n";
                     43: var_dump(count(new returnObject));
                     44: 
                     45: echo "Count returns an array:\n";
                     46: var_dump(count(new returnArray));
                     47: 
                     48: echo "Count throws an exception:\n";
                     49: try {
                     50:        echo count(new throwException);
                     51: } catch (Exception $e) {
                     52:        echo $e->getMessage();
                     53: }
                     54: 
                     55: ?>
                     56: --EXPECTF--
                     57: Count returns null:
                     58: int(0)
                     59: Count returns a string:
                     60: int(0)
                     61: Count returns an object:
                     62: 
                     63: Notice: Object of class returnObject could not be converted to int in %s on line 40
                     64: int(1)
                     65: Count returns an array:
                     66: int(1)
                     67: Count throws an exception:
                     68: Thrown from count

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