Skip to content

Commit b5eb97d

Browse files
author
Ricardo Fiorani
committed
test fix and small improvements
1 parent 26cab81 commit b5eb97d

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

src/Adapter/Vimeo/VimeoServiceAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public function isEmbeddable()
228228
*
229229
* @todo make this better by using guzzle
230230
*
231-
* @return array
231+
* @return \stdClass
232232
*
233233
* @throws ServiceApiNotAvailable
234234
*/

src/Container/ServicesContainer.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<?php
2-
/**
3-
* Created by PhpStorm.
4-
* User: Ricardo Fiorani
5-
* Date: 31/08/2015
6-
* Time: 21:06.
7-
*/
2+
83
namespace RicardoFiorani\Container;
94

105
use RicardoFiorani\Adapter\CallableServiceAdapterFactoryInterface;
@@ -68,14 +63,15 @@ private function registerFromConfig(array $config)
6863
foreach ($config['services'] as $serviceName => $serviceConfig) {
6964
$this->registerService($serviceName, $serviceConfig['patterns'], $serviceConfig['factory']);
7065
}
66+
7167
$this->setRenderer($config['renderer']['name'], $config['renderer']['factory']);
7268
}
7369

7470
/**
7571
* Register a Service.
7672
*
77-
* @param string $serviceName
78-
* @param array $regex
73+
* @param string $serviceName
74+
* @param array $regex
7975
* @param string|callable $factory
8076
*
8177
* @throws DuplicatedServiceNameException
@@ -84,7 +80,10 @@ public function registerService($serviceName, array $regex, $factory)
8480
{
8581
if ($this->hasService($serviceName)) {
8682
throw new DuplicatedServiceNameException(
87-
'The service "%s" is already registered in the container.', $serviceName
83+
sprintf(
84+
'The service "%s" is already registered in the container.',
85+
$serviceName
86+
)
8887
);
8988
}
9089

test/Container/ServicesContainerTest.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
<?php
2-
/**
3-
* Created by PhpStorm.
4-
* User: Ricardo Fiorani
5-
* Date: 10/02/2016
6-
* Time: 19:58
7-
*/
82

93
namespace RicardoFiorani\Test\Container;
104

11-
125
use PHPUnit_Framework_TestCase;
136
use RicardoFiorani\Container\ServicesContainer;
147
use stdClass;
@@ -31,8 +24,11 @@ public function testServiceContainerServiceRegistrationByInjection()
3124
});
3225

3326
$this->assertContains('TestService', $serviceContainer->getServiceNameList());
27+
3428
$this->setExpectedException('\\RicardoFiorani\\Container\\Exception\\DuplicatedServiceNameException');
29+
3530
$serviceContainer->registerService('TestService', array('#testPattern#'), function () {
31+
// @todo test the injected service maybe ?
3632
});
3733
}
3834

@@ -44,14 +40,15 @@ public function testServicesList()
4440
$this->assertContains('Youtube', $serviceContainer->getServices());
4541
}
4642

47-
public function testIfReturnsAlreadyInstantiatedFactory(){
43+
public function testIfReturnsAlreadyInstantiatedFactory()
44+
{
4845
$config = $this->getMockConfig();
4946
$serviceContainer = $this->createServiceContainer($config);
5047
$factory = $serviceContainer->getFactory('Youtube');
51-
$this->assertInstanceOf('\\RicardoFiorani\\Adapter\\Youtube\\Factory\\YoutubeServiceAdapterFactory',$factory);
48+
$this->assertInstanceOf('\\RicardoFiorani\\Adapter\\Youtube\\Factory\\YoutubeServiceAdapterFactory', $factory);
5249

5350
$alreadyInstantiatedFactory = $serviceContainer->getFactory('Youtube');
54-
$this->assertEquals($factory,$alreadyInstantiatedFactory);
51+
$this->assertEquals($factory, $alreadyInstantiatedFactory);
5552
}
5653

5754
/**

0 commit comments

Comments
 (0)