Esempio n. 1
0
 public function testConstructorAndGetters()
 {
     $p = new Permission('foo name', 'FOO_ROLE', 'foo_category', 'bar description');
     $this->assertEquals('foo name', $p->getName());
     $this->assertEquals('FOO_ROLE', $p->getRole());
     $this->assertEquals('foo_category', $p->getCategory());
     $this->assertEquals('bar description', $p->getDescription());
 }
 public function testInstallPermission()
 {
     $category = new PermissionCategoryEntity();
     $category->setName('Foo category');
     $category->setTechnicalName('foo_category');
     self::$em->persist($category);
     self::$em->flush();
     $permission = new Permission('foo name', 'FOO_ROLE', $category->getTechnicalName(), 'foo description');
     $pp = $this->permissionsProvider;
     $pp->expects($this->atLeastOnce())->method('getItems')->will($this->returnValue(array($permission)));
     $result = $this->installer->installPermissions();
     $this->assertValidResultStructure($result);
     $this->assertEquals(1, $result['installed']);
     $this->assertEquals(0, $result['removed']);
     /* @var PermissionEntity $installedPermission */
     $installedPermission = $this->getLastRecordInDatabase(PermissionEntity::clazz());
     $this->assertNotNull($installedPermission);
     $this->assertEquals($permission->getName(), $installedPermission->getName());
     $this->assertEquals($permission->getDescription(), $installedPermission->getDescription());
     $this->assertEquals($permission->getRole(), $installedPermission->getRole());
     $this->assertNotNull($installedPermission->getCategory());
     $this->assertEquals($category->getId(), $installedPermission->getCategory()->getId());
     // ---
     $result = $this->installer->installPermissions();
     $this->assertValidResultStructure($result);
     $this->assertEquals(0, $result['installed']);
     $this->assertEquals(0, $result['removed']);
 }