mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
moved magic methods
This commit is contained in:
@ -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
|
||||
*/
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user