pax_global_header00006660000000000000000000000064126066241110014511gustar00rootroot0000000000000052 comment=bc37d50fea7d017d3d340f230811c9f1d7280af4 global-state-1.1.1/000077500000000000000000000000001260662411100140675ustar00rootroot00000000000000global-state-1.1.1/.gitignore000066400000000000000000000001071260662411100160550ustar00rootroot00000000000000.idea composer.lock composer.phar vendor/ cache.properties phpunit.xml global-state-1.1.1/.travis.yml000066400000000000000000000003661260662411100162050ustar00rootroot00000000000000language: php php: - 5.3.3 - 5.3 - 5.4 - 5.5 - 5.6 - hhvm sudo: false before_script: - composer self-update - composer install --no-interaction --prefer-source --dev script: ./vendor/bin/phpunit notifications: email: false global-state-1.1.1/LICENSE000066400000000000000000000030121260662411100150700ustar00rootroot00000000000000GlobalState Copyright (c) 2001-2015, Sebastian Bergmann . All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Sebastian Bergmann nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. global-state-1.1.1/README.md000066400000000000000000000011471260662411100153510ustar00rootroot00000000000000# GlobalState Snapshotting of global state, factored out of PHPUnit into a stand-alone component. [![Build Status](https://travis-ci.org/sebastianbergmann/global-state.svg?branch=master)](https://travis-ci.org/sebastianbergmann/global-state) ## Installation To add this package as a local, per-project dependency to your project, simply add a dependency on `sebastian/global-state` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on GlobalState: { "require": { "sebastian/global-state": "1.0.*" } } global-state-1.1.1/build.xml000066400000000000000000000020351260662411100157100ustar00rootroot00000000000000 global-state-1.1.1/composer.json000066400000000000000000000014131260662411100166100ustar00rootroot00000000000000{ "name": "sebastian/global-state", "description": "Snapshotting of global state", "keywords": ["global state"], "homepage": "http://www.github.com/sebastianbergmann/global-state", "license": "BSD-3-Clause", "authors": [ { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" } ], "require": { "php": ">=5.3.3" }, "require-dev": { "phpunit/phpunit": "~4.2" }, "suggest": { "ext-uopz": "*" }, "autoload": { "classmap": [ "src/" ] }, "autoload-dev": { "classmap": [ "tests/_fixture/" ] }, "extra": { "branch-alias": { "dev-master": "1.0-dev" } } } global-state-1.1.1/phpunit.xml.dist000066400000000000000000000012221260662411100172370ustar00rootroot00000000000000 tests src global-state-1.1.1/src/000077500000000000000000000000001260662411100146565ustar00rootroot00000000000000global-state-1.1.1/src/Blacklist.php000066400000000000000000000061331260662411100173020ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\GlobalState; use ReflectionClass; /** * A blacklist for global state elements that should not be snapshotted. */ class Blacklist { /** * @var array */ private $globalVariables = array(); /** * @var array */ private $classes = array(); /** * @var array */ private $classNamePrefixes = array(); /** * @var array */ private $parentClasses = array(); /** * @var array */ private $interfaces = array(); /** * @var array */ private $staticAttributes = array(); /** * @param string $variableName */ public function addGlobalVariable($variableName) { $this->globalVariables[$variableName] = true; } /** * @param string $className */ public function addClass($className) { $this->classes[] = $className; } /** * @param string $className */ public function addSubclassesOf($className) { $this->parentClasses[] = $className; } /** * @param string $interfaceName */ public function addImplementorsOf($interfaceName) { $this->interfaces[] = $interfaceName; } /** * @param string $classNamePrefix */ public function addClassNamePrefix($classNamePrefix) { $this->classNamePrefixes[] = $classNamePrefix; } /** * @param string $className * @param string $attributeName */ public function addStaticAttribute($className, $attributeName) { if (!isset($this->staticAttributes[$className])) { $this->staticAttributes[$className] = array(); } $this->staticAttributes[$className][$attributeName] = true; } /** * @param string $variableName * @return bool */ public function isGlobalVariableBlacklisted($variableName) { return isset($this->globalVariables[$variableName]); } /** * @param string $className * @param string $attributeName * @return bool */ public function isStaticAttributeBlacklisted($className, $attributeName) { if (in_array($className, $this->classes)) { return true; } foreach ($this->classNamePrefixes as $prefix) { if (strpos($className, $prefix) === 0) { return true; } } $class = new ReflectionClass($className); foreach ($this->parentClasses as $type) { if ($class->isSubclassOf($type)) { return true; } } foreach ($this->interfaces as $type) { if ($class->implementsInterface($type)) { return true; } } if (isset($this->staticAttributes[$className][$attributeName])) { return true; } return false; } } global-state-1.1.1/src/CodeExporter.php000066400000000000000000000042331260662411100177740ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\GlobalState; /** * Exports parts of a Snapshot as PHP code. */ class CodeExporter { /** * @param Snapshot $snapshot * @return string */ public function constants(Snapshot $snapshot) { $result = ''; foreach ($snapshot->constants() as $name => $value) { $result .= sprintf( 'if (!defined(\'%s\')) define(\'%s\', %s);' . "\n", $name, $name, $this->exportVariable($value) ); } return $result; } /** * @param Snapshot $snapshot * @return string */ public function iniSettings(Snapshot $snapshot) { $result = ''; foreach ($snapshot->iniSettings() as $key => $value) { $result .= sprintf( '@ini_set(%s, %s);' . "\n", $this->exportVariable($key), $this->exportVariable($value) ); } return $result; } /** * @param mixed $variable * @return string */ private function exportVariable($variable) { if (is_scalar($variable) || is_null($variable) || (is_array($variable) && $this->arrayOnlyContainsScalars($variable))) { return var_export($variable, true); } return 'unserialize(' . var_export(serialize($variable), true) . ')'; } /** * @param array $array * @return bool */ private function arrayOnlyContainsScalars(array $array) { $result = true; foreach ($array as $element) { if (is_array($element)) { $result = self::arrayOnlyContainsScalars($element); } elseif (!is_scalar($element) && !is_null($element)) { $result = false; } if ($result === false) { break; } } return $result; } } global-state-1.1.1/src/Exception.php000066400000000000000000000004771260662411100173350ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\GlobalState; /** */ interface Exception { } global-state-1.1.1/src/Restorer.php000066400000000000000000000106471260662411100172040ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\GlobalState; use ReflectionProperty; /** * Restorer of snapshots of global state. */ class Restorer { /** * Deletes function definitions that are not defined in a snapshot. * * @param Snapshot $snapshot * @throws RuntimeException when the uopz_delete() function is not available * @see https://github.com/krakjoe/uopz */ public function restoreFunctions(Snapshot $snapshot) { if (!function_exists('uopz_delete')) { throw new RuntimeException('The uopz_delete() function is required for this operation'); } $functions = get_defined_functions(); foreach (array_diff($functions['user'], $snapshot->functions()) as $function) { uopz_delete($function); } } /** * Restores all global and super-global variables from a snapshot. * * @param Snapshot $snapshot */ public function restoreGlobalVariables(Snapshot $snapshot) { $superGlobalArrays = $snapshot->superGlobalArrays(); foreach ($superGlobalArrays as $superGlobalArray) { $this->restoreSuperGlobalArray($snapshot, $superGlobalArray); } $globalVariables = $snapshot->globalVariables(); foreach (array_keys($GLOBALS) as $key) { if ($key != 'GLOBALS' && !in_array($key, $superGlobalArrays) && !$snapshot->blacklist()->isGlobalVariableBlacklisted($key)) { if (isset($globalVariables[$key])) { $GLOBALS[$key] = $globalVariables[$key]; } else { unset($GLOBALS[$key]); } } } } /** * Restores all static attributes in user-defined classes from this snapshot. * * @param Snapshot $snapshot */ public function restoreStaticAttributes(Snapshot $snapshot) { $current = new Snapshot($snapshot->blacklist(), false, false, false, false, true, false, false, false, false); $newClasses = array_diff($current->classes(), $snapshot->classes()); unset($current); foreach ($snapshot->staticAttributes() as $className => $staticAttributes) { foreach ($staticAttributes as $name => $value) { $reflector = new ReflectionProperty($className, $name); $reflector->setAccessible(true); $reflector->setValue($value); } } foreach ($newClasses as $className) { $class = new \ReflectionClass($className); $defaults = $class->getDefaultProperties(); foreach ($class->getProperties() as $attribute) { if (!$attribute->isStatic()) { continue; } $name = $attribute->getName(); if ($snapshot->blacklist()->isStaticAttributeBlacklisted($className, $name)) { continue; } if (!isset($defaults[$name])) { continue; } $attribute->setAccessible(true); $attribute->setValue($defaults[$name]); } } } /** * Restores a super-global variable array from this snapshot. * * @param Snapshot $snapshot * @param $superGlobalArray */ private function restoreSuperGlobalArray(Snapshot $snapshot, $superGlobalArray) { $superGlobalVariables = $snapshot->superGlobalVariables(); if (isset($GLOBALS[$superGlobalArray]) && is_array($GLOBALS[$superGlobalArray]) && isset($superGlobalVariables[$superGlobalArray])) { $keys = array_keys( array_merge( $GLOBALS[$superGlobalArray], $superGlobalVariables[$superGlobalArray] ) ); foreach ($keys as $key) { if (isset($superGlobalVariables[$superGlobalArray][$key])) { $GLOBALS[$superGlobalArray][$key] = $superGlobalVariables[$superGlobalArray][$key]; } else { unset($GLOBALS[$superGlobalArray][$key]); } } } } } global-state-1.1.1/src/RuntimeException.php000066400000000000000000000005611260662411100206730ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\GlobalState; /** */ class RuntimeException extends \RuntimeException implements Exception { } global-state-1.1.1/src/Snapshot.php000066400000000000000000000227451260662411100172000ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\GlobalState; use ReflectionClass; use Serializable; /** * A snapshot of global state. */ class Snapshot { /** * @var Blacklist */ private $blacklist; /** * @var array */ private $globalVariables = array(); /** * @var array */ private $superGlobalArrays = array(); /** * @var array */ private $superGlobalVariables = array(); /** * @var array */ private $staticAttributes = array(); /** * @var array */ private $iniSettings = array(); /** * @var array */ private $includedFiles = array(); /** * @var array */ private $constants = array(); /** * @var array */ private $functions = array(); /** * @var array */ private $interfaces = array(); /** * @var array */ private $classes = array(); /** * @var array */ private $traits = array(); /** * Creates a snapshot of the current global state. * * @param Blacklist $blacklist * @param bool $includeGlobalVariables * @param bool $includeStaticAttributes * @param bool $includeConstants * @param bool $includeFunctions * @param bool $includeClasses * @param bool $includeInterfaces * @param bool $includeTraits * @param bool $includeIniSettings * @param bool $includeIncludedFiles */ public function __construct(Blacklist $blacklist = null, $includeGlobalVariables = true, $includeStaticAttributes = true, $includeConstants = true, $includeFunctions = true, $includeClasses = true, $includeInterfaces = true, $includeTraits = true, $includeIniSettings = true, $includeIncludedFiles = true) { if ($blacklist === null) { $blacklist = new Blacklist; } $this->blacklist = $blacklist; if ($includeConstants) { $this->snapshotConstants(); } if ($includeFunctions) { $this->snapshotFunctions(); } if ($includeClasses || $includeStaticAttributes) { $this->snapshotClasses(); } if ($includeInterfaces) { $this->snapshotInterfaces(); } if ($includeGlobalVariables) { $this->setupSuperGlobalArrays(); $this->snapshotGlobals(); } if ($includeStaticAttributes) { $this->snapshotStaticAttributes(); } if ($includeIniSettings) { $this->iniSettings = ini_get_all(null, false); } if ($includeIncludedFiles) { $this->includedFiles = get_included_files(); } if (function_exists('get_declared_traits')) { $this->traits = get_declared_traits(); } } /** * @return Blacklist */ public function blacklist() { return $this->blacklist; } /** * @return array */ public function globalVariables() { return $this->globalVariables; } /** * @return array */ public function superGlobalVariables() { return $this->superGlobalVariables; } /** * Returns a list of all super-global variable arrays. * * @return array */ public function superGlobalArrays() { return $this->superGlobalArrays; } /** * @return array */ public function staticAttributes() { return $this->staticAttributes; } /** * @return array */ public function iniSettings() { return $this->iniSettings; } /** * @return array */ public function includedFiles() { return $this->includedFiles; } /** * @return array */ public function constants() { return $this->constants; } /** * @return array */ public function functions() { return $this->functions; } /** * @return array */ public function interfaces() { return $this->interfaces; } /** * @return array */ public function classes() { return $this->classes; } /** * @return array */ public function traits() { return $this->traits; } /** * Creates a snapshot user-defined constants. */ private function snapshotConstants() { $constants = get_defined_constants(true); if (isset($constants['user'])) { $this->constants = $constants['user']; } } /** * Creates a snapshot user-defined functions. */ private function snapshotFunctions() { $functions = get_defined_functions(); $this->functions = $functions['user']; } /** * Creates a snapshot user-defined classes. */ private function snapshotClasses() { foreach (array_reverse(get_declared_classes()) as $className) { $class = new ReflectionClass($className); if (!$class->isUserDefined()) { break; } $this->classes[] = $className; } $this->classes = array_reverse($this->classes); } /** * Creates a snapshot user-defined interfaces. */ private function snapshotInterfaces() { foreach (array_reverse(get_declared_interfaces()) as $interfaceName) { $class = new ReflectionClass($interfaceName); if (!$class->isUserDefined()) { break; } $this->interfaces[] = $interfaceName; } $this->interfaces = array_reverse($this->interfaces); } /** * Creates a snapshot of all global and super-global variables. */ private function snapshotGlobals() { $superGlobalArrays = $this->superGlobalArrays(); foreach ($superGlobalArrays as $superGlobalArray) { $this->snapshotSuperGlobalArray($superGlobalArray); } foreach (array_keys($GLOBALS) as $key) { if ($key != 'GLOBALS' && !in_array($key, $superGlobalArrays) && $this->canBeSerialized($GLOBALS[$key]) && !$this->blacklist->isGlobalVariableBlacklisted($key)) { $this->globalVariables[$key] = unserialize(serialize($GLOBALS[$key])); } } } /** * Creates a snapshot a super-global variable array. * * @param $superGlobalArray */ private function snapshotSuperGlobalArray($superGlobalArray) { $this->superGlobalVariables[$superGlobalArray] = array(); if (isset($GLOBALS[$superGlobalArray]) && is_array($GLOBALS[$superGlobalArray])) { foreach ($GLOBALS[$superGlobalArray] as $key => $value) { $this->superGlobalVariables[$superGlobalArray][$key] = unserialize(serialize($value)); } } } /** * Creates a snapshot of all static attributes in user-defined classes. */ private function snapshotStaticAttributes() { foreach ($this->classes as $className) { $class = new ReflectionClass($className); $snapshot = array(); foreach ($class->getProperties() as $attribute) { if ($attribute->isStatic()) { $name = $attribute->getName(); if ($this->blacklist->isStaticAttributeBlacklisted($className, $name)) { continue; } $attribute->setAccessible(true); $value = $attribute->getValue(); if ($this->canBeSerialized($value)) { $snapshot[$name] = unserialize(serialize($value)); } } } if (!empty($snapshot)) { $this->staticAttributes[$className] = $snapshot; } } } /** * Returns a list of all super-global variable arrays. * * @return array */ private function setupSuperGlobalArrays() { $this->superGlobalArrays = array( '_ENV', '_POST', '_GET', '_COOKIE', '_SERVER', '_FILES', '_REQUEST' ); if (ini_get('register_long_arrays') == '1') { $this->superGlobalArrays = array_merge( $this->superGlobalArrays, array( 'HTTP_ENV_VARS', 'HTTP_POST_VARS', 'HTTP_GET_VARS', 'HTTP_COOKIE_VARS', 'HTTP_SERVER_VARS', 'HTTP_POST_FILES' ) ); } } /** * @param mixed $variable * @return bool * @todo Implement this properly */ private function canBeSerialized($variable) { if (!is_object($variable)) { return !is_resource($variable); } if ($variable instanceof \stdClass) { return true; } $class = new ReflectionClass($variable); do { if ($class->isInternal()) { return $variable instanceof Serializable; } } while ($class = $class->getParentClass()); return true; } } global-state-1.1.1/tests/000077500000000000000000000000001260662411100152315ustar00rootroot00000000000000global-state-1.1.1/tests/BlacklistTest.php000066400000000000000000000063161260662411100205200ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\GlobalState; use PHPUnit_Framework_TestCase; /** */ class BlacklistTest extends PHPUnit_Framework_TestCase { /** * @var \SebastianBergmann\GlobalState\Blacklist */ private $blacklist; protected function setUp() { $this->blacklist = new Blacklist; } public function testGlobalVariableThatIsNotBlacklistedIsNotTreatedAsBlacklisted() { $this->assertFalse($this->blacklist->isGlobalVariableBlacklisted('variable')); } public function testGlobalVariableCanBeBlacklisted() { $this->blacklist->addGlobalVariable('variable'); $this->assertTrue($this->blacklist->isGlobalVariableBlacklisted('variable')); } public function testStaticAttributeThatIsNotBlacklistedIsNotTreatedAsBlacklisted() { $this->assertFalse( $this->blacklist->isStaticAttributeBlacklisted( 'SebastianBergmann\GlobalState\TestFixture\BlacklistedClass', 'attribute' ) ); } public function testClassCanBeBlacklisted() { $this->blacklist->addClass('SebastianBergmann\GlobalState\TestFixture\BlacklistedClass'); $this->assertTrue( $this->blacklist->isStaticAttributeBlacklisted( 'SebastianBergmann\GlobalState\TestFixture\BlacklistedClass', 'attribute' ) ); } public function testSubclassesCanBeBlacklisted() { $this->blacklist->addSubclassesOf('SebastianBergmann\GlobalState\TestFixture\BlacklistedClass'); $this->assertTrue( $this->blacklist->isStaticAttributeBlacklisted( 'SebastianBergmann\GlobalState\TestFixture\BlacklistedChildClass', 'attribute' ) ); } public function testImplementorsCanBeBlacklisted() { $this->blacklist->addImplementorsOf('SebastianBergmann\GlobalState\TestFixture\BlacklistedInterface'); $this->assertTrue( $this->blacklist->isStaticAttributeBlacklisted( 'SebastianBergmann\GlobalState\TestFixture\BlacklistedImplementor', 'attribute' ) ); } public function testClassNamePrefixesCanBeBlacklisted() { $this->blacklist->addClassNamePrefix('SebastianBergmann\GlobalState'); $this->assertTrue( $this->blacklist->isStaticAttributeBlacklisted( 'SebastianBergmann\GlobalState\TestFixture\BlacklistedClass', 'attribute' ) ); } public function testStaticAttributeCanBeBlacklisted() { $this->blacklist->addStaticAttribute( 'SebastianBergmann\GlobalState\TestFixture\BlacklistedClass', 'attribute' ); $this->assertTrue( $this->blacklist->isStaticAttributeBlacklisted( 'SebastianBergmann\GlobalState\TestFixture\BlacklistedClass', 'attribute' ) ); } } global-state-1.1.1/tests/SnapshotTest.php000066400000000000000000000100321260662411100203750ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\GlobalState; use ArrayObject; use PHPUnit_Framework_TestCase; use SebastianBergmann\GlobalState\TestFixture\SnapshotClass; /** */ class SnapshotTest extends PHPUnit_Framework_TestCase { public function testStaticAttributes() { $blacklist = $this->getBlacklist(); $blacklist->method('isStaticAttributeBlacklisted')->willReturnCallback(function ($class) { return $class !== 'SebastianBergmann\GlobalState\TestFixture\SnapshotClass'; }); SnapshotClass::init(); $snapshot = new Snapshot($blacklist, false, true, false, false, false, false, false, false, false); $expected = array('SebastianBergmann\GlobalState\TestFixture\SnapshotClass' => array( 'string' => 'snapshot', 'arrayObject' => new ArrayObject(array(1, 2, 3)), 'stdClass' => new \stdClass(), )); $this->assertEquals($expected, $snapshot->staticAttributes()); } public function testConstants() { $snapshot = new Snapshot($this->getBlacklist(), false, false, true, false, false, false, false, false, false); $this->assertArrayHasKey('GLOBALSTATE_TESTSUITE', $snapshot->constants()); } public function testFunctions() { require_once __DIR__.'/_fixture/SnapshotFunctions.php'; $snapshot = new Snapshot($this->getBlacklist(), false, false, false, true, false, false, false, false, false); $functions = $snapshot->functions(); $this->assertThat( $functions, $this->logicalOr( // Zend $this->contains('sebastianbergmann\globalstate\testfixture\snapshotfunction'), // HHVM $this->contains('SebastianBergmann\GlobalState\TestFixture\snapshotFunction') ) ); $this->assertNotContains('assert', $functions); } public function testClasses() { $snapshot = new Snapshot($this->getBlacklist(), false, false, false, false, true, false, false, false, false); $classes = $snapshot->classes(); $this->assertContains('PHPUnit_Framework_TestCase', $classes); $this->assertNotContains('Exception', $classes); } public function testInterfaces() { $snapshot = new Snapshot($this->getBlacklist(), false, false, false, false, false, true, false, false, false); $interfaces = $snapshot->interfaces(); $this->assertContains('PHPUnit_Framework_Test', $interfaces); $this->assertNotContains('Countable', $interfaces); } /** * @requires PHP 5.4 */ public function testTraits() { spl_autoload_call('SebastianBergmann\GlobalState\TestFixture\SnapshotTrait'); $snapshot = new Snapshot($this->getBlacklist(), false, false, false, false, false, false, true, false, false); $this->assertContains('SebastianBergmann\GlobalState\TestFixture\SnapshotTrait', $snapshot->traits()); } public function testIniSettings() { $snapshot = new Snapshot($this->getBlacklist(), false, false, false, false, false, false, false, true, false); $iniSettings = $snapshot->iniSettings(); $this->assertArrayHasKey('date.timezone', $iniSettings); $this->assertEquals('Etc/UTC', $iniSettings['date.timezone']); } public function testIncludedFiles() { $snapshot = new Snapshot($this->getBlacklist(), false, false, false, false, false, false, false, false, true); $this->assertContains(__FILE__, $snapshot->includedFiles()); } /** * @return \SebastianBergmann\GlobalState\Blacklist */ private function getBlacklist() { return $this->getMockBuilder('SebastianBergmann\GlobalState\Blacklist') ->disableOriginalConstructor() ->getMock(); } } global-state-1.1.1/tests/_fixture/000077500000000000000000000000001260662411100170565ustar00rootroot00000000000000global-state-1.1.1/tests/_fixture/BlacklistedChildClass.php000066400000000000000000000005541260662411100237460ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\GlobalState\TestFixture; /** */ class BlacklistedChildClass extends BlacklistedClass { } global-state-1.1.1/tests/_fixture/BlacklistedClass.php000066400000000000000000000005551260662411100230030ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\GlobalState\TestFixture; /** */ class BlacklistedClass { private static $attribute; } global-state-1.1.1/tests/_fixture/BlacklistedImplementor.php000066400000000000000000000006231260662411100242250ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\GlobalState\TestFixture; /** */ class BlacklistedImplementor implements BlacklistedInterface { private static $attribute; } global-state-1.1.1/tests/_fixture/BlacklistedInterface.php000066400000000000000000000005261260662411100236340ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\GlobalState\TestFixture; /** */ interface BlacklistedInterface { } global-state-1.1.1/tests/_fixture/SnapshotClass.php000066400000000000000000000016621260662411100223610ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\GlobalState\TestFixture; use DomDocument; use ArrayObject; /** */ class SnapshotClass { private static $string = 'snapshot'; private static $dom; private static $closure; private static $arrayObject; private static $snapshotDomDocument; private static $resource; private static $stdClass; public static function init() { self::$dom = new DomDocument(); self::$closure = function () {}; self::$arrayObject = new ArrayObject(array(1, 2, 3)); self::$snapshotDomDocument = new SnapshotDomDocument(); self::$resource = fopen('php://memory', 'r'); self::$stdClass = new \stdClass(); } } global-state-1.1.1/tests/_fixture/SnapshotDomDocument.php000066400000000000000000000005671260662411100235350ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\GlobalState\TestFixture; use DomDocument; /** */ class SnapshotDomDocument extends DomDocument { } global-state-1.1.1/tests/_fixture/SnapshotFunctions.php000066400000000000000000000005131260662411100232560ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\GlobalState\TestFixture; function snapshotFunction() { } global-state-1.1.1/tests/_fixture/SnapshotTrait.php000066400000000000000000000005131260662411100223710ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\GlobalState\TestFixture; /** */ trait SnapshotTrait { }