From 13e85adc8e74a0431acab046372254a3425d2b3c Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 3 Feb 2014 22:58:08 +0400 Subject: [PATCH] moved magic methods --- extensions/codeception/TestCase.php | 39 ++++++++++++++++++++++++++++ framework/test/FixtureTrait.php | 40 ----------------------------- 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/extensions/codeception/TestCase.php b/extensions/codeception/TestCase.php index fe9638fe42..d1cfb7fa84 100644 --- a/extensions/codeception/TestCase.php +++ b/extensions/codeception/TestCase.php @@ -25,6 +25,45 @@ class TestCase extends Test */ public $appConfig = '@tests/unit/_config.php'; + /** + * Returns the value of an object property. + * + * Do not call this method directly as it is a PHP magic method that + * will be implicitly called when executing `$value = $object->property;`. + * @param string $name the property name + * @return mixed the property value + * @throws UnknownPropertyException if the property is not defined + */ + public function __get($name) + { + $fixture = $this->getFixture($name); + if ($fixture !== null) { + return $fixture; + } else { + throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name); + } + } + + /** + * Calls the named method which is not a class method. + * + * Do not call this method directly as it is a PHP magic method that + * will be implicitly called when an unknown method is being invoked. + * @param string $name the method name + * @param array $params method parameters + * @throws UnknownMethodException when calling unknown method + * @return mixed the method return value + */ + public function __call($name, $params) + { + $fixture = $this->getFixture($name); + if ($fixture instanceof ActiveFixture) { + return $fixture->getModel(reset($params)); + } else { + throw new UnknownMethodException('Unknown method: ' . get_class($this) . "::$name()"); + } + } + /** * @inheritdoc */ diff --git a/framework/test/FixtureTrait.php b/framework/test/FixtureTrait.php index fc8fafa888..59216d79f9 100644 --- a/framework/test/FixtureTrait.php +++ b/framework/test/FixtureTrait.php @@ -38,46 +38,6 @@ trait FixtureTrait */ private $_fixtureAliases; - - /** - * Returns the value of an object property. - * - * Do not call this method directly as it is a PHP magic method that - * will be implicitly called when executing `$value = $object->property;`. - * @param string $name the property name - * @return mixed the property value - * @throws UnknownPropertyException if the property is not defined - */ - public function __get($name) - { - $fixture = $this->getFixture($name); - if ($fixture !== null) { - return $fixture; - } else { - throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name); - } - } - - /** - * Calls the named method which is not a class method. - * - * Do not call this method directly as it is a PHP magic method that - * will be implicitly called when an unknown method is being invoked. - * @param string $name the method name - * @param array $params method parameters - * @throws UnknownMethodException when calling unknown method - * @return mixed the method return value - */ - public function __call($name, $params) - { - $fixture = $this->getFixture($name); - if ($fixture instanceof ActiveFixture) { - return $fixture->getModel(reset($params)); - } else { - throw new UnknownMethodException('Unknown method: ' . get_class($this) . "::$name()"); - } - } - /** * Declares the fixtures that are needed by the current test case. * The return value of this method must be an array of fixture configurations. For example,