Vendor lock
This commit is contained in:
117
vendor/sebastian/global-state/tests/BlacklistTest.php
vendored
Normal file
117
vendor/sebastian/global-state/tests/BlacklistTest.php
vendored
Normal file
@ -0,0 +1,117 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/global-state.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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;
|
||||
use SebastianBergmann\GlobalState\TestFixture\BlacklistedChildClass;
|
||||
use SebastianBergmann\GlobalState\TestFixture\BlacklistedClass;
|
||||
use SebastianBergmann\GlobalState\TestFixture\BlacklistedImplementor;
|
||||
use SebastianBergmann\GlobalState\TestFixture\BlacklistedInterface;
|
||||
|
||||
/**
|
||||
* @covers \SebastianBergmann\GlobalState\Blacklist
|
||||
*/
|
||||
final class BlacklistTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var \SebastianBergmann\GlobalState\Blacklist
|
||||
*/
|
||||
private $blacklist;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->blacklist = new Blacklist;
|
||||
}
|
||||
|
||||
public function testGlobalVariableThatIsNotBlacklistedIsNotTreatedAsBlacklisted(): void
|
||||
{
|
||||
$this->assertFalse($this->blacklist->isGlobalVariableBlacklisted('variable'));
|
||||
}
|
||||
|
||||
public function testGlobalVariableCanBeBlacklisted(): void
|
||||
{
|
||||
$this->blacklist->addGlobalVariable('variable');
|
||||
|
||||
$this->assertTrue($this->blacklist->isGlobalVariableBlacklisted('variable'));
|
||||
}
|
||||
|
||||
public function testStaticAttributeThatIsNotBlacklistedIsNotTreatedAsBlacklisted(): void
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->blacklist->isStaticAttributeBlacklisted(
|
||||
BlacklistedClass::class,
|
||||
'attribute'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testClassCanBeBlacklisted(): void
|
||||
{
|
||||
$this->blacklist->addClass(BlacklistedClass::class);
|
||||
|
||||
$this->assertTrue(
|
||||
$this->blacklist->isStaticAttributeBlacklisted(
|
||||
BlacklistedClass::class,
|
||||
'attribute'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testSubclassesCanBeBlacklisted(): void
|
||||
{
|
||||
$this->blacklist->addSubclassesOf(BlacklistedClass::class);
|
||||
|
||||
$this->assertTrue(
|
||||
$this->blacklist->isStaticAttributeBlacklisted(
|
||||
BlacklistedChildClass::class,
|
||||
'attribute'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testImplementorsCanBeBlacklisted(): void
|
||||
{
|
||||
$this->blacklist->addImplementorsOf(BlacklistedInterface::class);
|
||||
|
||||
$this->assertTrue(
|
||||
$this->blacklist->isStaticAttributeBlacklisted(
|
||||
BlacklistedImplementor::class,
|
||||
'attribute'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testClassNamePrefixesCanBeBlacklisted(): void
|
||||
{
|
||||
$this->blacklist->addClassNamePrefix('SebastianBergmann\GlobalState');
|
||||
|
||||
$this->assertTrue(
|
||||
$this->blacklist->isStaticAttributeBlacklisted(
|
||||
BlacklistedClass::class,
|
||||
'attribute'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testStaticAttributeCanBeBlacklisted(): void
|
||||
{
|
||||
$this->blacklist->addStaticAttribute(
|
||||
BlacklistedClass::class,
|
||||
'attribute'
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$this->blacklist->isStaticAttributeBlacklisted(
|
||||
BlacklistedClass::class,
|
||||
'attribute'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
35
vendor/sebastian/global-state/tests/CodeExporterTest.php
vendored
Normal file
35
vendor/sebastian/global-state/tests/CodeExporterTest.php
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/global-state.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @covers \SebastianBergmann\GlobalState\CodeExporter
|
||||
*/
|
||||
final class CodeExporterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testCanExportGlobalVariablesToCode(): void
|
||||
{
|
||||
$GLOBALS = ['foo' => 'bar'];
|
||||
|
||||
$snapshot = new Snapshot(null, true, false, false, false, false, false, false, false, false);
|
||||
|
||||
$exporter = new CodeExporter;
|
||||
|
||||
$this->assertEquals(
|
||||
'$GLOBALS = [];' . \PHP_EOL . '$GLOBALS[\'foo\'] = \'bar\';' . \PHP_EOL,
|
||||
$exporter->globalVariables($snapshot)
|
||||
);
|
||||
}
|
||||
}
|
68
vendor/sebastian/global-state/tests/RestorerTest.php
vendored
Normal file
68
vendor/sebastian/global-state/tests/RestorerTest.php
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/global-state.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @covers \SebastianBergmann\GlobalState\Restorer
|
||||
*
|
||||
* @uses \SebastianBergmann\GlobalState\Blacklist
|
||||
* @uses \SebastianBergmann\GlobalState\Snapshot
|
||||
*/
|
||||
final class RestorerTest extends TestCase
|
||||
{
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
$GLOBALS['varBool'] = false;
|
||||
$GLOBALS['varNull'] = null;
|
||||
$_GET['varGet'] = 0;
|
||||
}
|
||||
|
||||
public function testRestorerGlobalVariable(): void
|
||||
{
|
||||
$snapshot = new Snapshot(null, true, false, false, false, false, false, false, false, false);
|
||||
$restorer = new Restorer;
|
||||
$restorer->restoreGlobalVariables($snapshot);
|
||||
|
||||
$this->assertArrayHasKey('varBool', $GLOBALS);
|
||||
$this->assertEquals(false, $GLOBALS['varBool']);
|
||||
$this->assertArrayHasKey('varNull', $GLOBALS);
|
||||
$this->assertEquals(null, $GLOBALS['varNull']);
|
||||
$this->assertArrayHasKey('varGet', $_GET);
|
||||
$this->assertEquals(0, $_GET['varGet']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @backupGlobals enabled
|
||||
*/
|
||||
public function testIntegrationRestorerGlobalVariables(): void
|
||||
{
|
||||
$this->assertArrayHasKey('varBool', $GLOBALS);
|
||||
$this->assertEquals(false, $GLOBALS['varBool']);
|
||||
$this->assertArrayHasKey('varNull', $GLOBALS);
|
||||
$this->assertEquals(null, $GLOBALS['varNull']);
|
||||
$this->assertArrayHasKey('varGet', $_GET);
|
||||
$this->assertEquals(0, $_GET['varGet']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testIntegrationRestorerGlobalVariables
|
||||
*/
|
||||
public function testIntegrationRestorerGlobalVariables2(): void
|
||||
{
|
||||
$this->assertArrayHasKey('varBool', $GLOBALS);
|
||||
$this->assertEquals(false, $GLOBALS['varBool']);
|
||||
$this->assertArrayHasKey('varNull', $GLOBALS);
|
||||
$this->assertEquals(null, $GLOBALS['varNull']);
|
||||
$this->assertArrayHasKey('varGet', $_GET);
|
||||
$this->assertEquals(0, $_GET['varGet']);
|
||||
}
|
||||
}
|
120
vendor/sebastian/global-state/tests/SnapshotTest.php
vendored
Normal file
120
vendor/sebastian/global-state/tests/SnapshotTest.php
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/global-state.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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;
|
||||
use SebastianBergmann\GlobalState\TestFixture\BlacklistedInterface;
|
||||
use SebastianBergmann\GlobalState\TestFixture\SnapshotClass;
|
||||
use SebastianBergmann\GlobalState\TestFixture\SnapshotTrait;
|
||||
|
||||
/**
|
||||
* @covers \SebastianBergmann\GlobalState\Snapshot
|
||||
*
|
||||
* @uses \SebastianBergmann\GlobalState\Blacklist
|
||||
*/
|
||||
final class SnapshotTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Blacklist
|
||||
*/
|
||||
private $blacklist;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->blacklist = new Blacklist;
|
||||
}
|
||||
|
||||
public function testStaticAttributes(): void
|
||||
{
|
||||
SnapshotClass::init();
|
||||
|
||||
$this->blacklistAllLoadedClassesExceptSnapshotClass();
|
||||
|
||||
$snapshot = new Snapshot($this->blacklist, false, true, false, false, false, false, false, false, false);
|
||||
|
||||
$expected = [
|
||||
SnapshotClass::class => [
|
||||
'string' => 'string',
|
||||
'objects' => [new \stdClass],
|
||||
],
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $snapshot->staticAttributes());
|
||||
}
|
||||
|
||||
public function testConstants(): void
|
||||
{
|
||||
$snapshot = new Snapshot($this->blacklist, false, false, true, false, false, false, false, false, false);
|
||||
|
||||
$this->assertArrayHasKey('GLOBALSTATE_TESTSUITE', $snapshot->constants());
|
||||
}
|
||||
|
||||
public function testFunctions(): void
|
||||
{
|
||||
$snapshot = new Snapshot($this->blacklist, false, false, false, true, false, false, false, false, false);
|
||||
$functions = $snapshot->functions();
|
||||
|
||||
$this->assertContains('sebastianbergmann\globalstate\testfixture\snapshotfunction', $functions);
|
||||
$this->assertNotContains('assert', $functions);
|
||||
}
|
||||
|
||||
public function testClasses(): void
|
||||
{
|
||||
$snapshot = new Snapshot($this->blacklist, false, false, false, false, true, false, false, false, false);
|
||||
$classes = $snapshot->classes();
|
||||
|
||||
$this->assertContains(TestCase::class, $classes);
|
||||
$this->assertNotContains(Exception::class, $classes);
|
||||
}
|
||||
|
||||
public function testInterfaces(): void
|
||||
{
|
||||
$snapshot = new Snapshot($this->blacklist, false, false, false, false, false, true, false, false, false);
|
||||
$interfaces = $snapshot->interfaces();
|
||||
|
||||
$this->assertContains(BlacklistedInterface::class, $interfaces);
|
||||
$this->assertNotContains(\Countable::class, $interfaces);
|
||||
}
|
||||
|
||||
public function testTraits(): void
|
||||
{
|
||||
\spl_autoload_call('SebastianBergmann\GlobalState\TestFixture\SnapshotTrait');
|
||||
|
||||
$snapshot = new Snapshot($this->blacklist, false, false, false, false, false, false, true, false, false);
|
||||
|
||||
$this->assertContains(SnapshotTrait::class, $snapshot->traits());
|
||||
}
|
||||
|
||||
public function testIniSettings(): void
|
||||
{
|
||||
$snapshot = new Snapshot($this->blacklist, 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(): void
|
||||
{
|
||||
$snapshot = new Snapshot($this->blacklist, false, false, false, false, false, false, false, false, true);
|
||||
$this->assertContains(__FILE__, $snapshot->includedFiles());
|
||||
}
|
||||
|
||||
private function blacklistAllLoadedClassesExceptSnapshotClass(): void
|
||||
{
|
||||
foreach (\get_declared_classes() as $class) {
|
||||
if ($class === SnapshotClass::class) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->blacklist->addClass($class);
|
||||
}
|
||||
}
|
||||
}
|
14
vendor/sebastian/global-state/tests/_fixture/BlacklistedChildClass.php
vendored
Normal file
14
vendor/sebastian/global-state/tests/_fixture/BlacklistedChildClass.php
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/global-state.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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
|
||||
{
|
||||
}
|
15
vendor/sebastian/global-state/tests/_fixture/BlacklistedClass.php
vendored
Normal file
15
vendor/sebastian/global-state/tests/_fixture/BlacklistedClass.php
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/global-state.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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;
|
||||
}
|
15
vendor/sebastian/global-state/tests/_fixture/BlacklistedImplementor.php
vendored
Normal file
15
vendor/sebastian/global-state/tests/_fixture/BlacklistedImplementor.php
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/global-state.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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;
|
||||
}
|
14
vendor/sebastian/global-state/tests/_fixture/BlacklistedInterface.php
vendored
Normal file
14
vendor/sebastian/global-state/tests/_fixture/BlacklistedInterface.php
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/global-state.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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
|
||||
{
|
||||
}
|
35
vendor/sebastian/global-state/tests/_fixture/SnapshotClass.php
vendored
Normal file
35
vendor/sebastian/global-state/tests/_fixture/SnapshotClass.php
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/global-state.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace SebastianBergmann\GlobalState\TestFixture;
|
||||
|
||||
class SnapshotClass
|
||||
{
|
||||
private static $string = 'string';
|
||||
|
||||
private static $closures = [];
|
||||
|
||||
private static $files = [];
|
||||
|
||||
private static $resources = [];
|
||||
|
||||
private static $objects = [];
|
||||
|
||||
public static function init(): void
|
||||
{
|
||||
self::$closures[] = function (): void {
|
||||
};
|
||||
|
||||
self::$files[] = new \SplFileInfo(__FILE__);
|
||||
|
||||
self::$resources[] = \fopen('php://memory', 'r');
|
||||
|
||||
self::$objects[] = new \stdClass;
|
||||
}
|
||||
}
|
16
vendor/sebastian/global-state/tests/_fixture/SnapshotDomDocument.php
vendored
Normal file
16
vendor/sebastian/global-state/tests/_fixture/SnapshotDomDocument.php
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/global-state.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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
|
||||
{
|
||||
}
|
14
vendor/sebastian/global-state/tests/_fixture/SnapshotFunctions.php
vendored
Normal file
14
vendor/sebastian/global-state/tests/_fixture/SnapshotFunctions.php
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/global-state.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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(): void
|
||||
{
|
||||
}
|
14
vendor/sebastian/global-state/tests/_fixture/SnapshotTrait.php
vendored
Normal file
14
vendor/sebastian/global-state/tests/_fixture/SnapshotTrait.php
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/global-state.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user