5���#��a`,>����������1T���W�����{X�ɘ�}G�4�"��ҕ4z�5F>e6*��[��\�;��%*U0LUUr2�cp�n��ݢ�kɜ��Y��͌3��+bG�����0#el���۴�o�e,,�jO�*M���1X��/3�z�)W^�,p>��s{��İQs��:�ޝd|w
���:f�I��e$���~�+ajX�jnT8����0'���S��>KI�UP���&���kN
Server IP : 78.111.106.131 / Your IP : 13.59.55.237 Web Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_fcgid/2.3.9 PHP/7.2.34 System : User : nobody ( 99) PHP Version : 7.2.34 Disable Function : proc_open,system,passthru,exec,popen,shell_exec,dbmopen,suexec,escapeshellcmd,show_source,escapeshellarg,symlink,eval,php_uname,pcntl_exec MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /webler/tggtd.org/core/vendor/swiftmailer/swiftmailer/tests/unit/Swift/ |
Upload File : |
<?php class One { public $arg1; public $arg2; public function __construct($arg1 = null, $arg2 = null) { $this->arg1 = $arg1; $this->arg2 = $arg2; } } class Swift_DependencyContainerTest extends \PHPUnit\Framework\TestCase { private $container; protected function setUp() { $this->container = new Swift_DependencyContainer(); } public function testRegisterAndLookupValue() { $this->container->register('foo')->asValue('bar'); $this->assertEquals('bar', $this->container->lookup('foo')); } public function testHasReturnsTrueForRegisteredValue() { $this->container->register('foo')->asValue('bar'); $this->assertTrue($this->container->has('foo')); } public function testHasReturnsFalseForUnregisteredValue() { $this->assertFalse($this->container->has('foo')); } public function testRegisterAndLookupNewInstance() { $this->container->register('one')->asNewInstanceOf('One'); $this->assertInstanceOf('One', $this->container->lookup('one')); } public function testHasReturnsTrueForRegisteredInstance() { $this->container->register('one')->asNewInstanceOf('One'); $this->assertTrue($this->container->has('one')); } public function testNewInstanceIsAlwaysNew() { $this->container->register('one')->asNewInstanceOf('One'); $a = $this->container->lookup('one'); $b = $this->container->lookup('one'); $this->assertEquals($a, $b); } public function testRegisterAndLookupSharedInstance() { $this->container->register('one')->asSharedInstanceOf('One'); $this->assertInstanceOf('One', $this->container->lookup('one')); } public function testHasReturnsTrueForSharedInstance() { $this->container->register('one')->asSharedInstanceOf('One'); $this->assertTrue($this->container->has('one')); } public function testMultipleSharedInstancesAreSameInstance() { $this->container->register('one')->asSharedInstanceOf('One'); $a = $this->container->lookup('one'); $b = $this->container->lookup('one'); $this->assertEquals($a, $b); } public function testRegisterAndLookupArray() { $this->container->register('One')->asArray(); $this->assertSame([], $this->container->lookup('One')); } public function testNewInstanceWithDependencies() { $this->container->register('foo')->asValue('FOO'); $this->container->register('one')->asNewInstanceOf('One') ->withDependencies(['foo']); $obj = $this->container->lookup('one'); $this->assertSame('FOO', $obj->arg1); } public function testNewInstanceWithMultipleDependencies() { $this->container->register('foo')->asValue('FOO'); $this->container->register('bar')->asValue(42); $this->container->register('one')->asNewInstanceOf('One') ->withDependencies(['foo', 'bar']); $obj = $this->container->lookup('one'); $this->assertSame('FOO', $obj->arg1); $this->assertSame(42, $obj->arg2); } public function testNewInstanceWithInjectedObjects() { $this->container->register('foo')->asValue('FOO'); $this->container->register('one')->asNewInstanceOf('One'); $this->container->register('two')->asNewInstanceOf('One') ->withDependencies(['one', 'foo']); $obj = $this->container->lookup('two'); $this->assertEquals($this->container->lookup('one'), $obj->arg1); $this->assertSame('FOO', $obj->arg2); } public function testNewInstanceWithAddConstructorValue() { $this->container->register('one')->asNewInstanceOf('One') ->addConstructorValue('x') ->addConstructorValue(99); $obj = $this->container->lookup('one'); $this->assertSame('x', $obj->arg1); $this->assertSame(99, $obj->arg2); } public function testNewInstanceWithAddConstructorLookup() { $this->container->register('foo')->asValue('FOO'); $this->container->register('bar')->asValue(42); $this->container->register('one')->asNewInstanceOf('One') ->addConstructorLookup('foo') ->addConstructorLookup('bar'); $obj = $this->container->lookup('one'); $this->assertSame('FOO', $obj->arg1); $this->assertSame(42, $obj->arg2); } public function testResolvedDependenciesCanBeLookedUp() { $this->container->register('foo')->asValue('FOO'); $this->container->register('one')->asNewInstanceOf('One'); $this->container->register('two')->asNewInstanceOf('One') ->withDependencies(['one', 'foo']); $deps = $this->container->createDependenciesFor('two'); $this->assertEquals( [$this->container->lookup('one'), 'FOO'], $deps ); } public function testArrayOfDependenciesCanBeSpecified() { $this->container->register('foo')->asValue('FOO'); $this->container->register('one')->asNewInstanceOf('One'); $this->container->register('two')->asNewInstanceOf('One') ->withDependencies([['one', 'foo'], 'foo']); $obj = $this->container->lookup('two'); $this->assertEquals([$this->container->lookup('one'), 'FOO'], $obj->arg1); $this->assertSame('FOO', $obj->arg2); } public function testArrayWithDependencies() { $this->container->register('foo')->asValue('FOO'); $this->container->register('bar')->asValue(42); $this->container->register('one')->asArray('One') ->withDependencies(['foo', 'bar']); $this->assertSame(['FOO', 42], $this->container->lookup('one')); } public function testAliasCanBeSet() { $this->container->register('foo')->asValue('FOO'); $this->container->register('bar')->asAliasOf('foo'); $this->assertSame('FOO', $this->container->lookup('bar')); } public function testAliasOfAliasCanBeSet() { $this->container->register('foo')->asValue('FOO'); $this->container->register('bar')->asAliasOf('foo'); $this->container->register('zip')->asAliasOf('bar'); $this->container->register('button')->asAliasOf('zip'); $this->assertSame('FOO', $this->container->lookup('button')); } }