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

Commit

Permalink
use mock instead of concrete object
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefano Torresi committed Oct 31, 2013
1 parent 4ad8580 commit c35c23c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 49 deletions.
34 changes: 21 additions & 13 deletions test/ServiceManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,27 @@ public function testCallingANonExistingServiceFromAnAbstractServiceDoesNotMakeTh
$this->assertInstanceOf('stdClass', $service);
}

public function testMultipleAbstractFactoriesWithOneLookingForANonExistingServiceDuringCanCreate()
{
$abstractFactory = new TestAsset\TrollAbstractFactory;
$anotherAbstractFactory = $this->getMock('Zend\ServiceManager\AbstractFactoryInterface');
$anotherAbstractFactory
->expects($this->exactly(2))
->method('canCreateServiceWithName')
->with(
$this->serviceManager,
$this->logicalOr('somethingthatcanbecreated', 'nonexistingservice'),
$this->logicalOr('SomethingThatCanBeCreated', 'NonExistingService')
)
->will($this->returnValue(false));

$this->serviceManager->addAbstractFactory($abstractFactory);
$this->serviceManager->addAbstractFactory($anotherAbstractFactory);

$this->assertTrue($this->serviceManager->has('SomethingThatCanBeCreated'));
$this->assertFalse($abstractFactory->inexistingServiceCheckResult);
}

public function testWaitingAbstractFactory()
{
$abstractFactory = new TestAsset\WaitingAbstractFactory;
Expand Down Expand Up @@ -1101,17 +1122,4 @@ public function getServiceOfVariousTypes()
array(tmpfile())
);
}

public function testMultipleAbstractFactoriesLookingForANonExistingServiceDuringCanCreatePhase()
{
$abstractFactory = new TestAsset\TrollAbstractFactory;
$anotherAbstractFactory = new TestAsset\AnotherTrollAbstractFactory;

$this->serviceManager->addAbstractFactory($abstractFactory);
$this->serviceManager->addAbstractFactory($anotherAbstractFactory);

$this->assertTrue($this->serviceManager->has('anothertroll'));
$this->assertFalse($abstractFactory->inexistingServiceCheckResult);
$this->assertFalse($anotherAbstractFactory->inexistingServiceCheckResult);
}
}
36 changes: 0 additions & 36 deletions test/TestAsset/AnotherTrollAbstractFactory.php

This file was deleted.

0 comments on commit c35c23c

Please sign in to comment.