File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Zend/tests/property_hooks Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 1
1
--TEST--
2
- Hooks work on backed readonly properties
2
+ Readonly hooks may be lazy loaded
3
3
--FILE--
4
4
<?php
5
5
@@ -45,16 +45,24 @@ $categoryId->setValue($product, '42');
45
45
$ category1 = $ product ->category ;
46
46
echo $ category1 ->name . "\n" ;
47
47
48
- // cached value
48
+ // cached category returned
49
49
$ category2 = $ product ->category ;
50
50
echo $ category2 ->name . "\n" ;
51
51
52
- // Verify same instance is returned (backing field caching works)
52
+ // same category instance returned
53
53
var_dump ($ category1 === $ category2 );
54
54
55
+ // cannot set twice
56
+ try {
57
+ $ categoryId ->setValue ($ product , '420 ' );
58
+ } catch (Error $ e ) {
59
+ echo $ e ->getMessage (), "\n" ;
60
+ }
61
+
55
62
?>
56
63
--EXPECT--
57
64
hit database
58
65
Category 42
59
66
Category 42
60
67
bool(true)
68
+ Cannot modify readonly property LazyProduct::$categoryId
You can’t perform that action at this time.
0 commit comments