mirror of
https://github.com/dg/dibi.git
synced 2025-08-29 00:39:50 +02:00
DibiObject: simplified to minimum (BC break)
Removed support for setters, onEvent(), getClass() & getReflection(). Retained support for getters and extension methods.
This commit is contained in:
@@ -7,6 +7,11 @@ require __DIR__ . '/bootstrap.php';
|
||||
|
||||
class TestClass extends DibiObject
|
||||
{
|
||||
public function callParent()
|
||||
{
|
||||
parent::callParent();
|
||||
}
|
||||
|
||||
public function getBar()
|
||||
{
|
||||
return 123;
|
||||
@@ -29,17 +34,22 @@ Assert::exception(function () {
|
||||
TestClass::undeclared();
|
||||
}, 'LogicException', 'Call to undefined static method TestClass::undeclared().');
|
||||
|
||||
Assert::exception(function () {
|
||||
$obj = new TestClass;
|
||||
$obj->callParent();
|
||||
}, 'LogicException', 'Call to undefined method parent::callParent().');
|
||||
|
||||
|
||||
// writing
|
||||
Assert::exception(function () {
|
||||
$obj = new TestClass;
|
||||
$obj->undeclared = 'value';
|
||||
}, 'LogicException', 'Cannot assign to an undeclared property TestClass::$undeclared.');
|
||||
}, 'LogicException', 'Attempt to write to undeclared property TestClass::$undeclared.');
|
||||
|
||||
|
||||
// property getter
|
||||
$obj = new TestClass;
|
||||
Assert::true(isset($obj->bar));
|
||||
Assert::false(isset($obj->bar));
|
||||
Assert::same(123, $obj->bar);
|
||||
Assert::false(isset($obj->foo));
|
||||
Assert::same(456, $obj->foo);
|
||||
@@ -49,14 +59,14 @@ Assert::same(456, $obj->foo);
|
||||
Assert::exception(function () {
|
||||
$obj = new TestClass;
|
||||
$val = $obj->undeclared;
|
||||
}, 'LogicException', 'Cannot read an undeclared property TestClass::$undeclared.');
|
||||
}, 'LogicException', 'Attempt to read undeclared property TestClass::$undeclared.');
|
||||
|
||||
|
||||
// unset/isset
|
||||
Assert::exception(function () {
|
||||
$obj = new TestClass;
|
||||
unset($obj->undeclared);
|
||||
}, 'LogicException', 'Cannot unset the property TestClass::$undeclared.');
|
||||
}, 'LogicException', 'Attempt to unset undeclared property TestClass::$undeclared.');
|
||||
|
||||
Assert::false(isset($obj->undeclared));
|
||||
|
||||
|
Reference in New Issue
Block a user