Skip to content

Commit 3fffdae

Browse files
committed
Merge pull request #46 from drupol/Add-missing-tests
Add missing Unit tests.
2 parents 369de70 + bd4afb6 commit 3fffdae

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

src/DependencyInjection/Container.php

-2
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ public function initialized($id) {
401401
* @return string
402402
* The camelized string.
403403
*
404-
* @codeCoverageIgnore
405404
*/
406405
public static function camelize($name) {
407406
return strtr(ucwords(strtr($name, array('_' => ' ', '\\' => '_ '))), array(' ' => ''));
@@ -416,7 +415,6 @@ public static function camelize($name) {
416415
* @return string
417416
* The underscored string.
418417
*
419-
* @codeCoverageIgnore
420418
*/
421419
public static function underscore($name) {
422420
return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), $name));

tests/src/DependencyInjection/ContainerTest.php

+35
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,41 @@ public function test_initialized() {
385385
$this->assertTrue($this->container->initialized('late.service'), 'Late service is initialized after it was gotten.');
386386
}
387387

388+
/**
389+
* Camelizes a string.
390+
*
391+
* @covers ::camelize
392+
* @dataProvider underscoreCamelizeDataProvider
393+
*/
394+
public function test_camelize($string_underscore, $string_camelize) {
395+
$result = $this->container->camelize($string_underscore);
396+
$this->assertEquals($string_camelize, $result);
397+
}
398+
399+
/**
400+
* Un-camelizes a string.
401+
*
402+
* @covers ::underscore
403+
* @dataProvider underscoreCamelizeDataProvider
404+
*/
405+
public function test_underscore($string_underscore, $string_camelize) {
406+
$result = $this->container->underscore($string_camelize);
407+
$this->assertEquals($string_underscore, $result);
408+
}
409+
410+
/**
411+
* Data Provider for ::underscore and ::camelize.
412+
*/
413+
public function underscoreCamelizeDataProvider() {
414+
return array(
415+
array('service_container', 'ServiceContainer'),
416+
array('service_container_symfony', 'ServiceContainerSymfony'),
417+
array('123service_container', '123serviceContainer'),
418+
array('123service_container_symfony', '123serviceContainerSymfony'),
419+
array('123service_container', '123serviceContainer'),
420+
array('123service_container_symfony', '123serviceContainerSymfony'),
421+
);
422+
}
388423

389424
/**
390425
* Returns a mock container definition.

0 commit comments

Comments
 (0)