summaryrefslogtreecommitdiffstats
path: root/Tests/Acl/Domain/ObjectIdentityTest.php
diff options
context:
space:
mode:
authorChristian Flothmann <christian.flothmann@xabbuh.de>2015-05-31 17:00:49 +0200
committerChristian Flothmann <christian.flothmann@xabbuh.de>2015-05-31 17:00:49 +0200
commit1bd6c22e4ef584f059b5f0aa3591e651ad70f806 (patch)
tree1f7b6e868ed6fbfe8b8941ca76e33f4bd1d7ee6c /Tests/Acl/Domain/ObjectIdentityTest.php
parentb3d032613d74a7d5d7babeee28d9ac8f870ff36c (diff)
downloadsymfony-security-1bd6c22e4ef584f059b5f0aa3591e651ad70f806.zip
symfony-security-1bd6c22e4ef584f059b5f0aa3591e651ad70f806.tar.gz
symfony-security-1bd6c22e4ef584f059b5f0aa3591e651ad70f806.tar.bz2
[Security][Acl] enforce string identifiers
Diffstat (limited to 'Tests/Acl/Domain/ObjectIdentityTest.php')
-rw-r--r--Tests/Acl/Domain/ObjectIdentityTest.php24
1 files changed, 23 insertions, 1 deletions
diff --git a/Tests/Acl/Domain/ObjectIdentityTest.php b/Tests/Acl/Domain/ObjectIdentityTest.php
index 9281fd5..111ae8a 100644
--- a/Tests/Acl/Domain/ObjectIdentityTest.php
+++ b/Tests/Acl/Domain/ObjectIdentityTest.php
@@ -64,6 +64,26 @@ namespace Symfony\Component\Security\Tests\Acl\Domain
$this->assertEquals('Symfony\Component\Security\Tests\Acl\Domain\TestDomainObject', $id->getType());
}
+ public function testFromDomainObjectWithoutInterfaceEnforcesStringIdentifier()
+ {
+ $domainObject = new TestDomainObject();
+ $domainObject->id = 1;
+ $id = ObjectIdentity::fromDomainObject($domainObject);
+
+ $this->assertSame('1', $id->getIdentifier());
+ $this->assertEquals('Symfony\Component\Security\Tests\Acl\Domain\TestDomainObject', $id->getType());
+ }
+
+ public function testFromDomainObjectWithoutInterfaceAllowsZeroAsIdentifier()
+ {
+ $domainObject = new TestDomainObject();
+ $domainObject->id = '0';
+ $id = ObjectIdentity::fromDomainObject($domainObject);
+
+ $this->assertSame('0', $id->getIdentifier());
+ $this->assertEquals('Symfony\Component\Security\Tests\Acl\Domain\TestDomainObject', $id->getType());
+ }
+
/**
* @dataProvider getCompareData
*/
@@ -89,6 +109,8 @@ namespace Symfony\Component\Security\Tests\Acl\Domain
class TestDomainObject
{
+ public $id = 'getId()';
+
public function getObjectIdentifier()
{
return 'getObjectIdentifier()';
@@ -96,7 +118,7 @@ namespace Symfony\Component\Security\Tests\Acl\Domain
public function getId()
{
- return 'getId()';
+ return $this->id;
}
}
}