propel-bundle/Tests/Model/EntryTest.php
Drew Brown ea6a359272 Symfony 4.0 updates (#483)
* Upd: Add Symfony 4 Compatibility

#SymfonyConHackday2017

* Upd: Configure visibility of services for SF4

* Updated composer to allow Symfony 4.0

* Updated composer to allow Symfony 4.0

* PropelBundle for Symfony 4

* Upd: Travis configuration

* Upd: PHP 5 not supported anymore by PHPUnit

* Upd: Removing old SF version + PHPUnit correction

* * Removed param that was removed in symfony/yaml afb873f
* Updated format of object dumping as deprecated tags using colon symfony/yaml 38d3087

* * Added commands to console.xml as symfony no longer auto registers bundle commands
* Updated two services to public

* * Removed deprecated getMock calls for new createMock calls.

* * Add stub for additional abstract method

* * Updated schema locator test
* reverted unnecessary changes to abstract command and schemal locator
* Added fixtures for schema testing.

* * Updated schema locator test
* reverted unnecessary changes to abstract command and schemal locator
* Added fixtures for schema testing.

* * Removed unnecessary default for services
* Updated readme to reflect symfony version support
2018-02-10 01:25:14 +01:00

94 lines
3 KiB
PHP

<?php
/**
* This file is part of the PropelBundle package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
namespace Propel\Bundle\PropelBundle\Tests\Model\Acl;
use Propel\Bundle\PropelBundle\Model\Acl\Entry as ModelEntry;
use Propel\Bundle\PropelBundle\Model\Acl\SecurityIdentity;
use Propel\Bundle\PropelBundle\Security\Acl\Domain\Entry as AclEntry;
use Propel\Bundle\PropelBundle\Tests\AclTestCase;
/**
* @author Toni Uebernickel <tuebernickel@gmail.com>
*/
class EntryTest extends AclTestCase
{
public function testToAclEntry()
{
$acl = $this->getMockBuilder('Propel\Bundle\PropelBundle\Security\Acl\Domain\AuditableAcl')
->disableOriginalConstructor()
->getMock();
$entry = $this->createModelEntry();
$aclEntry = ModelEntry::toAclEntry($entry, $acl);
$this->assertInstanceOf('Propel\Bundle\PropelBundle\Security\Acl\Domain\Entry', $aclEntry);
$this->assertSame($acl, $aclEntry->getAcl());
$this->assertEquals(42, $aclEntry->getId());
$this->assertTrue($aclEntry->isAuditFailure());
$this->assertFalse($aclEntry->isAuditSuccess());
$this->assertEquals('all', $aclEntry->getStrategy());
$this->assertTrue($aclEntry->isGranting());
$this->assertEquals(64, $aclEntry->getMask());
return $aclEntry;
}
/**
* @depends testToAclEntry
*/
public function testToAclEntryFieldEntry()
{
$acl = $this->getMockBuilder('Propel\Bundle\PropelBundle\Security\Acl\Domain\AuditableAcl')
->disableOriginalConstructor()
->getMock();
$entry = $this->createModelEntry();
$entry->setFieldName('name');
$aclEntry = ModelEntry::toAclEntry($entry, $acl);
$this->assertInstanceOf('Propel\Bundle\PropelBundle\Security\Acl\Domain\FieldEntry', $aclEntry);
}
/**
* @depends testToAclEntry
*/
public function testFromAclEntry($aclEntry)
{
$modelEntry = ModelEntry::fromAclEntry($aclEntry);
$this->assertInstanceOf('Propel\Bundle\PropelBundle\Model\Acl\Entry', $modelEntry);
$this->assertEquals(42, $modelEntry->getId());
$this->assertTrue($modelEntry->getAuditFailure());
$this->assertFalse($modelEntry->getAuditSuccess());
$this->assertEquals('all', $modelEntry->getGrantingStrategy());
$this->assertTrue($modelEntry->getGranting());
$this->assertEquals(64, $modelEntry->getMask());
}
protected function createModelEntry()
{
$entry = new ModelEntry();
$entry
->setId(42)
->setAclClass($this->getAclClass())
->setSecurityIdentity(SecurityIdentity::fromAclIdentity($this->getRoleSecurityIdentity()))
->setAuditFailure(true)
->setAuditSuccess(false)
->setGrantingStrategy('all')
->setGranting(true)
->setMask(64)
;
return $entry;
}
}