public function testCloneModes() { $this->config->is_deep = false; $this->config->deep[] = 'user'; $this->assertTrue($this->config->propertyIsShallowCloned('profile')); $this->assertFalse($this->config->propertyIsShallowCloned('user')); $this->assertTrue($this->config->propertyIsDeeplyCloned('user')); }
/** * @param $properties * @return array */ private function specifyCloneProperties($properties) { foreach ($properties as $property => $val) { if ($this->specifyConfig->propertyIgnored($property)) { continue; } if ($this->specifyConfig->classIgnored($val)) { continue; } if ($this->specifyConfig->propertyIsShallowCloned($property)) { if (is_object($val)) { $this->{$property} = clone $val; } else { $this->{$property} = $val; } } if ($this->specifyConfig->propertyIsDeeplyCloned($property)) { $this->{$property} = $this->copier->copy($val); } } }
/** * @return ObjectProperty[] */ private function getSpecifyObjectProperties() { $objectReflection = new \ReflectionObject($this); $propertiesToClone = $objectReflection->getProperties(); if (($classProperties = $this->specifyGetClassPrivateProperties()) !== []) { $propertiesToClone = array_merge($propertiesToClone, $classProperties); } $properties = []; foreach ($propertiesToClone as $property) { if ($this->specifyConfig->propertyIgnored($property->getName())) { continue; } $properties[] = new ObjectProperty($this, $property); } // isolate mockObjects property from PHPUnit_Framework_TestCase if (($phpUnitReflection = $this->specifyGetPhpUnitReflection()) !== null) { $properties[] = $mockObjects = new ObjectProperty($this, $phpUnitReflection->getProperty('mockObjects')); // remove all mock objects inherited from parent scope(s) $mockObjects->setValue([]); } return $properties; }
/** * Executed before each test. * * @param TestInterface $test */ public function _before(TestInterface $test) { $this->test = $test; SpecifyConfig::setDeepClone(false); }
<?php // This is global bootstrap for autoloading require_once __DIR__ . '/../src/ArchiDelivery/Autoloader.php'; use ArchiDelivery\Autoloader; Autoloader::init(); \Codeception\Specify\Config::setDeepClone(false);
public function specifyConfig() { if (!$this->specifyConfig) { $this->specifyConfig = Config::create(); } return new ConfigBuilder($this->specifyConfig); }