Skip to content
This repository has been archived by the owner on Feb 6, 2020. It is now read-only.

Commit

Permalink
Applied corrections as of PR #242 to this.
Browse files Browse the repository at this point in the history
  • Loading branch information
fhein committed Feb 2, 2018
1 parent 665025c commit f3f96c1
Showing 1 changed file with 40 additions and 9 deletions.
49 changes: 40 additions & 9 deletions test/ServiceManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,51 +276,82 @@ public function testFactoryMayBeStaticMethodDescribedByCallableString()
$this->assertEquals(stdClass::class, get_class($serviceManager->get(stdClass::class)));
}

public function testMemberBasedConfigurationGetsApplied()
public function testMemberBasedAliasConfugrationGetsApplied()
{
$sm = new PreconfiguredServiceManager();

// will be true if $aliases array is properly setup and
// simple alias resolution works
$this->assertTrue($sm->has('alias2'));
$this->assertInstanceOf(stdClass::class, $sm->get('alias2'));
}

public function testMemberBasedRecursiveAliasConfugrationGetsApplied()
{
$sm = new PreconfiguredServiceManager();

// will be true if $aliases array is properly setup and
// recursive alias resolution works
$this->assertTrue($sm->has('alias1'));
$this->assertInstanceOf(stdClass::class, $sm->get('alias1'));
}

// will be true if $aliases array is properly setup and
// simple alias resolution works
$this->assertTrue($sm->has('alias2'));
$this->assertInstanceOf(stdClass::class, $sm->get('alias2'));
public function testMemberBasedServiceConfugrationGetsApplied()
{
$sm = new PreconfiguredServiceManager();

// will return true if $services array is properly setup
$this->assertTrue($sm->has('service'));
$this->assertInstanceOf(stdClass::class, $sm->get('service'));
}

public function testMemberBasedDelegatorConfugrationGetsApplied()
{
$sm = new PreconfiguredServiceManager();

// will be true if factory array is properly setup
$this->assertTrue($sm->has('delegator'));
$this->assertInstanceOf(InvokableObject::class, $sm->get('delegator'));

// will be true if initializer is present
$this->assertTrue($sm->get('delegator')->initializerPresent);
$this->assertObjectHasAttribute('initializerPresent', $sm->get('delegator'));
}

public function testMemberBasedFactoryConfugrationGetsApplied()
{
$sm = new PreconfiguredServiceManager();

// will be true if factory array is properly setup
$this->assertTrue($sm->has('factory'));
$this->assertInstanceOf(InvokableObject::class, $sm->get('factory'));

// will be true if initializer is present
$this->assertTrue($sm->get('factory')->initializerPresent);
$this->assertObjectHasAttribute('initializerPresent', $sm->get('delegator'));
}

public function testMemberBasedInvokableConfigurationGetsApplied()
{
$sm = new PreconfiguredServiceManager();

// will succeed if invokable is properly set up
$this->assertTrue($sm->has('invokable'));
$this->assertInstanceOf(stdClass::class, $sm->get('invokable'));

// will be true if initializer is present
$this->assertTrue($sm->get('invokable')->initializerPresent);
$this->assertObjectHasAttribute('initializerPresent', $sm->get('delegator'));
}

public function testMemberBasedAbstractFactoryConfigurationGetsApplied()
{
$sm = new PreconfiguredServiceManager();


// will succeed if abstract factory is available
$this->assertTrue($sm->has('foo'));
$this->assertInstanceOf(Foo::class, $sm->get('foo'));

// will be true if initializer is present
$this->assertTrue($sm->get('foo')->initializerPresent);
$this->assertObjectHasAttribute('initializerPresent', $sm->get('delegator'));
}

public function testInvokablesShouldNotOverrideFactoriesAndDelegators()
Expand Down

0 comments on commit f3f96c1

Please sign in to comment.