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

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2 into zf11884
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Kellner committed Nov 19, 2011
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class Container extends ArrayObject
*/
public function __construct($name = 'Default', $manager = null)
{
if (!preg_match('/^[a-z][a-z0-9_]+$/i', $name)) {
throw new Exception\InvalidArgumentException('Name passed to container is invalid; must consist of alphanumerics and underscores only');
if (!preg_match('/^[a-z][a-z0-9_\\\]+$/i', $name)) {
throw new Exception\InvalidArgumentException('Name passed to container is invalid; must consist of alphanumerics, backslashes and underscores only');
}
$this->_name = $name;
$this->_setManager($manager);
Expand Down
14 changes: 14 additions & 0 deletions test/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ public function testPassingNameToConstructorInstantiatesContainerWithThatName()
$this->assertEquals('foo', $container->getName());
}

public function testUsingOldZF1NameIsStillValid()
{
$container = new Container('Zend_Foo', $this->manager);
$this->assertEquals('Zend_Foo', $container->getName());
}

public function testUsingNewZF2NamespaceIsValid()
{
$container = new Container('Zend\Foo', $this->manager);
$this->assertEquals('Zend\Foo', $container->getName());
}

public function testPassingInvalidNameToConstructorRaisesException()
{
$tries = array(
Expand All @@ -101,6 +113,8 @@ public function testPassingInvalidNameToConstructorRaisesException()
'_foo',
'__foo',
'0foo',
'\foo',
'\\foo'
);
foreach ($tries as $try) {
try {
Expand Down

0 comments on commit 3617ea6

Please sign in to comment.