diff --git a/.travis.yml b/.travis.yml index c3d05cb..f60a06e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,33 +3,26 @@ sudo: false language: php php: - - 5.5 - - 5.6 - 7.0 - - nightly - - hhvm + - 7.1 + - 7.2 cache: directories: - $HOME/.composer/cache/files env: - - SYMFONY_VERSION="^2.8" - - SYMFONY_VERSION="^2.8" COMPOSER_FLAGS="--prefer-lowest" - SYMFONY_VERSION="^3.0" - - SYMFONY_VERSION="^3.0" COMPOSER_FLAGS="--prefer-lowest" - - SYMFONY_VERSION="dev-master" + - SYMFONY_VERSION="^4.0" matrix: fast_finish: true - allow_failures: - - php: hhvm - - php: nightly - - env: SYMFONY_VERSION="dev-master" + exclude: + - php: 7.0 + env: SYMFONY_VERSION="^4.0" before_install: - - phpenv config-rm xdebug.ini - composer self-update - if [ "${SYMFONY_VERSION}" != "" ]; then composer require --no-update "symfony/symfony:${SYMFONY_VERSION}"; fi; diff --git a/DataCollector/PropelDataCollector.php b/DataCollector/PropelDataCollector.php index 9e7d71e..09ea546 100644 --- a/DataCollector/PropelDataCollector.php +++ b/DataCollector/PropelDataCollector.php @@ -1,12 +1,11 @@ - * +/** + * 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\DataCollector; @@ -105,4 +104,12 @@ class PropelDataCollector extends DataCollector { return count($this->logger->getQueries()); } + + /** + * @inheritdoc + */ + public function reset() + { + // TODO: Implement reset() method. + } } diff --git a/DataFixtures/Dumper/YamlDataDumper.php b/DataFixtures/Dumper/YamlDataDumper.php index 32a6d7a..319f7ae 100644 --- a/DataFixtures/Dumper/YamlDataDumper.php +++ b/DataFixtures/Dumper/YamlDataDumper.php @@ -28,8 +28,7 @@ class YamlDataDumper extends AbstractDataDumper $data, $inline = 3, $indent = 4, - $exceptionOnInvalidType = false, - $objectSupport = true + Yaml::DUMP_OBJECT ); } } diff --git a/DependencyInjection/PropelExtension.php b/DependencyInjection/PropelExtension.php index 62b5c68..37193cb 100644 --- a/DependencyInjection/PropelExtension.php +++ b/DependencyInjection/PropelExtension.php @@ -53,6 +53,7 @@ class PropelExtension extends Extension $loader->load('propel.xml'); $loader->load('converters.xml'); $loader->load('security.xml'); + $loader->load('console.xml'); } } diff --git a/README.markdown b/README.markdown index 96d346a..165f4b2 100644 --- a/README.markdown +++ b/README.markdown @@ -1,7 +1,7 @@ PropelBundle ============ -[![Build Status](https://travis-ci.org/propelorm/PropelBundle.svg?branch=3.0)](https://travis-ci.org/propelorm/PropelBundle) +[![Build Status](https://travis-ci.org/propelorm/PropelBundle.svg?branch=4.0)](https://travis-ci.org/propelorm/PropelBundle) This is the official implementation of [Propel](http://www.propelorm.org/) in Symfony. @@ -14,6 +14,7 @@ As `Propel2` will be released in the near future, we are migrating the branching * The `1.2` branch contains Propel *1.6* integration for Symfony *2.2* (*currently master branch*). * The `2.0` branch contains `Propel2` integration for Symfony *2.5-2.8*. * The `3.0` branch contains `Propel2` integration for Symfony *2.8-3.x*. +* The `4.0` branch contains `Propel2` integration for Symfony *3.4-4.x*. ## Features diff --git a/Resources/config/console.xml b/Resources/config/console.xml new file mode 100644 index 0000000..24ff87a --- /dev/null +++ b/Resources/config/console.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Resources/config/propel.xml b/Resources/config/propel.xml index 8c70031..71d43c2 100644 --- a/Resources/config/propel.xml +++ b/Resources/config/propel.xml @@ -19,12 +19,12 @@ - + %propel.configuration% - + @@ -62,5 +62,7 @@ %kernel.root_dir% %propel.configuration% + + diff --git a/Service/SchemaLocator.php b/Service/SchemaLocator.php index d25ff0c..3d844b0 100644 --- a/Service/SchemaLocator.php +++ b/Service/SchemaLocator.php @@ -85,6 +85,6 @@ class SchemaLocator $schema->getRealPath() ); - return sprintf('@%s/Resources/config/%s', $bundle->getName(), $schemaPath); + return sprintf('%s/Resources/config/%s', $bundle->getName(), $schemaPath); } } diff --git a/Tests/DataFixtures/Dumper/YamlDataDumperTest.php b/Tests/DataFixtures/Dumper/YamlDataDumperTest.php index caef987..8d25985 100644 --- a/Tests/DataFixtures/Dumper/YamlDataDumperTest.php +++ b/Tests/DataFixtures/Dumper/YamlDataDumperTest.php @@ -51,17 +51,11 @@ class YamlDataDumperTest extends TestCase id: '1' name: 'An important one' author_id: CoolBookAuthor_1 - complementary_infos: !php/object:O:8:"stdClass":1:{s:15:"first_word_date";s:10:"2012-01-01";} + complementary_infos: !php/object 'O:8:"stdClass":1:{s:15:"first_word_date";s:10:"2012-01-01";}' YAML; - $result = file_get_contents($filename); - //yaml changed the way objects are serialized in - // -> https://github.com/symfony/yaml/commit/d5a7902da7e5af069bb8fdcfcf029a229deb1111 - //so we need to replace old behavior with new, to get this test working in all versions - $result = str_replace(' !!php/object', ' !php/object', $result); - $this->assertEquals($expected, $result); } } diff --git a/Tests/Fixtures/FakeBundle/FakeBundle.php b/Tests/Fixtures/FakeBundle/FakeBundle.php new file mode 100644 index 0000000..a632679 --- /dev/null +++ b/Tests/Fixtures/FakeBundle/FakeBundle.php @@ -0,0 +1,17 @@ +setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); EntryQuery::create()->findByAclIdentity($this->getAclObjectIdentity(), array('foo'), $this->con); } public function testFindByAclIdentityInvalidSecurityIdentityObject() { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); EntryQuery::create()->findByAclIdentity($this->getAclObjectIdentity(), array(new \stdClass()), $this->con); } diff --git a/Tests/Model/EntryTest.php b/Tests/Model/EntryTest.php index ae28f6f..546642e 100644 --- a/Tests/Model/EntryTest.php +++ b/Tests/Model/EntryTest.php @@ -24,7 +24,10 @@ class EntryTest extends AclTestCase { public function testToAclEntry() { - $acl = $this->getMock('Propel\Bundle\PropelBundle\Security\Acl\Domain\AuditableAcl', array(), array(), '', false, false); + $acl = $this->getMockBuilder('Propel\Bundle\PropelBundle\Security\Acl\Domain\AuditableAcl') + ->disableOriginalConstructor() + ->getMock(); + $entry = $this->createModelEntry(); $aclEntry = ModelEntry::toAclEntry($entry, $acl); @@ -45,7 +48,9 @@ class EntryTest extends AclTestCase */ public function testToAclEntryFieldEntry() { - $acl = $this->getMock('Propel\Bundle\PropelBundle\Security\Acl\Domain\AuditableAcl', array(), array(), '', false, false); + $acl = $this->getMockBuilder('Propel\Bundle\PropelBundle\Security\Acl\Domain\AuditableAcl') + ->disableOriginalConstructor() + ->getMock(); $entry = $this->createModelEntry(); $entry->setFieldName('name'); diff --git a/Tests/Model/ObjectIdentityQueryTest.php b/Tests/Model/ObjectIdentityQueryTest.php index f145e56..9da9b36 100644 --- a/Tests/Model/ObjectIdentityQueryTest.php +++ b/Tests/Model/ObjectIdentityQueryTest.php @@ -80,7 +80,7 @@ class ObjectIdentityQueryTest extends AclTestCase $result = ObjectIdentityQuery::create()->findChildren($objIdentity, $this->con); $this->assertCount(1, $result); $this->assertInstanceOf('Propel\Bundle\PropelBundle\Model\Acl\ObjectIdentity', $result->getFirst()); - $this->assertSame($childObjIdentity, $result->getFirst()); + $this->assertEquals($childObjIdentity, $result->getFirst()); $this->assertSame($objIdentity, $result->getFirst()->getObjectIdentityRelatedByParentObjectIdentityId()); } diff --git a/Tests/Model/SecurityIdentityTest.php b/Tests/Model/SecurityIdentityTest.php index 4081707..9e350f5 100644 --- a/Tests/Model/SecurityIdentityTest.php +++ b/Tests/Model/SecurityIdentityTest.php @@ -30,7 +30,7 @@ class SecurityIdentityTest extends AclTestCase $identity->setIdentifier('invalidIdentifier'); $identity->setUsername(true); - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); SecurityIdentity::toAclIdentity($identity); } @@ -40,7 +40,7 @@ class SecurityIdentityTest extends AclTestCase $identity->setIdentifier('invalidIdentifier'); $identity->setUsername(false); - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); SecurityIdentity::toAclIdentity($identity); } @@ -84,9 +84,9 @@ class SecurityIdentityTest extends AclTestCase public function testFromAclIdentityWithInvalid() { - $secIdentity = $this->getMock('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface'); + $secIdentity = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface')->getMock(); - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); SecurityIdentity::fromAclIdentity($secIdentity, $this->con); } diff --git a/Tests/Security/Acl/AclProviderTest.php b/Tests/Security/Acl/AclProviderTest.php index 2f363d2..24fa4f4 100644 --- a/Tests/Security/Acl/AclProviderTest.php +++ b/Tests/Security/Acl/AclProviderTest.php @@ -33,7 +33,7 @@ class AclProviderTest extends AclTestCase { $provider = $this->getAclProvider(); - $this->setExpectedException('Symfony\Component\Security\Acl\Exception\AclNotFoundException', 'There is no ACL available for this object identity. Please create one using the MutableAclProvider.'); + $this->expectException('Symfony\Component\Security\Acl\Exception\AclNotFoundException', 'There is no ACL available for this object identity. Please create one using the MutableAclProvider.'); $provider->findAcl($this->getAclObjectIdentity()); } @@ -41,7 +41,7 @@ class AclProviderTest extends AclTestCase { $provider = $this->getAclProvider(); - $this->setExpectedException('Symfony\Component\Security\Acl\Exception\AclNotFoundException', 'There is at least no ACL for this object identity and the given security identities. Try retrieving the ACL without security identity filter and add ACEs for the security identities.'); + $this->expectException('Symfony\Component\Security\Acl\Exception\AclNotFoundException', 'There is at least no ACL for this object identity and the given security identities. Try retrieving the ACL without security identity filter and add ACEs for the security identities.'); $provider->findAcl($this->getAclObjectIdentity(), array($this->getRoleSecurityIdentity())); } @@ -74,7 +74,7 @@ class AclProviderTest extends AclTestCase $this->assertTrue($acl->isGranted(array(1, 2, 4, 8, 16, 32, 64), array($this->getRoleSecurityIdentity('ROLE_USER')))); - $this->setExpectedException('Symfony\Component\Security\Acl\Exception\NoAceFoundException'); + $this->expectException('Symfony\Component\Security\Acl\Exception\NoAceFoundException'); $acl->isGranted(array(128), array($this->getRoleSecurityIdentity('ROLE_USER'))); } diff --git a/Tests/Security/Acl/Domain/AclTest.php b/Tests/Security/Acl/Domain/AclTest.php index ee6726b..07bfc05 100644 --- a/Tests/Security/Acl/Domain/AclTest.php +++ b/Tests/Security/Acl/Domain/AclTest.php @@ -29,7 +29,7 @@ class AclTest extends AclTestCase $collection = new ObjectCollection(); $collection->setModel('Propel\Bundle\PropelBundle\Model\Acl\AclClass'); - $this->setExpectedException('Symfony\Component\Security\Acl\Exception\Exception'); + $this->expectException('Symfony\Component\Security\Acl\Exception\Exception'); new Acl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy()); } @@ -138,7 +138,7 @@ class AclTest extends AclTestCase $aclObj = $this->getAclObjectIdentity(); $acl = new Acl($collection, $aclObj, new PermissionGrantingStrategy()); - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $acl->isSidLoaded('foo'); } @@ -149,7 +149,7 @@ class AclTest extends AclTestCase $acl = new Acl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy()); - $this->setExpectedException('Symfony\Component\Security\Acl\Exception\NoAceFoundException'); + $this->expectException('Symfony\Component\Security\Acl\Exception\NoAceFoundException'); $acl->isGranted(array(64), array($this->getRoleSecurityIdentity())); } @@ -167,7 +167,7 @@ class AclTest extends AclTestCase $acl = new Acl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy()); - $this->setExpectedException('Symfony\Component\Security\Acl\Exception\NoAceFoundException'); + $this->expectException('Symfony\Component\Security\Acl\Exception\NoAceFoundException'); $acl->isGranted(array(64), array($this->getRoleSecurityIdentity('ROLE_USER'))); } @@ -178,7 +178,7 @@ class AclTest extends AclTestCase $acl = new Acl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy()); - $this->setExpectedException('Symfony\Component\Security\Acl\Exception\NoAceFoundException'); + $this->expectException('Symfony\Component\Security\Acl\Exception\NoAceFoundException'); $acl->isFieldGranted('name', array(64), array($this->getRoleSecurityIdentity())); } diff --git a/Tests/Security/Acl/Domain/AuditableAclTest.php b/Tests/Security/Acl/Domain/AuditableAclTest.php index 3fd362c..1afff0d 100644 --- a/Tests/Security/Acl/Domain/AuditableAclTest.php +++ b/Tests/Security/Acl/Domain/AuditableAclTest.php @@ -31,7 +31,7 @@ class AuditableAclTest extends AclTestCase $acl = new AuditableAcl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy()); - $this->setExpectedException('OutOfBoundsException'); + $this->expectException('OutOfBoundsException'); $acl->updateObjectAuditing(0, false, false); } @@ -51,7 +51,7 @@ class AuditableAclTest extends AclTestCase $collection->append($entry); $acl = new AuditableAcl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy()); - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $acl->updateObjectFieldAuditing(0, 'foo', false, false); } @@ -70,7 +70,7 @@ class AuditableAclTest extends AclTestCase $collection->append($entry); $acl = new AuditableAcl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy()); - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $acl->updateObjectAuditing(0, 'foo', 'bar'); } diff --git a/Tests/Security/Acl/Domain/MutableAclTest.php b/Tests/Security/Acl/Domain/MutableAclTest.php index bd1f551..fcb42a3 100644 --- a/Tests/Security/Acl/Domain/MutableAclTest.php +++ b/Tests/Security/Acl/Domain/MutableAclTest.php @@ -30,7 +30,7 @@ class MutableAclTest extends AclTestCase $collection = new ObjectCollection(); $collection->setModel('Propel\Bundle\PropelBundle\Model\Acl\AclClass'); - $this->setExpectedException('Symfony\Component\Security\Acl\Exception\Exception'); + $this->expectException('Symfony\Component\Security\Acl\Exception\Exception'); new MutableAcl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy(), array(), null, false, $this->con); } @@ -68,14 +68,14 @@ class MutableAclTest extends AclTestCase public function testInsertAceInvalidMask() { $acl = $this->createEmptyAcl(); - $this->setExpectedException('InvalidArgumentException', 'The given mask is not valid. Please provide an integer.'); + $this->expectException('InvalidArgumentException', 'The given mask is not valid. Please provide an integer.'); $acl->insertClassAce($this->getRoleSecurityIdentity(), 'foo'); } public function testInsertAceOutofBounds() { $acl = $this->createEmptyAcl(); - $this->setExpectedException('OutOfBoundsException', 'The index must be in the interval [0, 0].'); + $this->expectException('OutOfBoundsException', 'The index must be in the interval [0, 0].'); $acl->insertClassAce($this->getRoleSecurityIdentity(), 64, 1); } @@ -120,7 +120,7 @@ class MutableAclTest extends AclTestCase public function testUpdateAceInvalidIndex() { $acl = $this->createEmptyAcl(); - $this->setExpectedException('OutOfBoundsException'); + $this->expectException('OutOfBoundsException'); $acl->updateClassAce(0, 64); } @@ -132,7 +132,7 @@ class MutableAclTest extends AclTestCase $acl = $this->createEmptyAcl(); $acl->insertClassAce($this->getRoleSecurityIdentity(), 64); - $this->setExpectedException('InvalidArgumentException', 'The given field "name" does not exist.'); + $this->expectException('InvalidArgumentException', 'The given field "name" does not exist.'); $acl->updateClassFieldAce(0, 'name', 128); } diff --git a/Tests/Security/Acl/MutableAclProviderTest.php b/Tests/Security/Acl/MutableAclProviderTest.php index 5ecd369..74fcc74 100644 --- a/Tests/Security/Acl/MutableAclProviderTest.php +++ b/Tests/Security/Acl/MutableAclProviderTest.php @@ -83,7 +83,7 @@ class MutableAclProviderTest extends AclTestCase $acl->insertObjectAce($this->getRoleSecurityIdentity(), 64); $this->getAclProvider()->updateAcl($acl); - $this->setExpectedException('Symfony\Component\Security\Acl\Exception\AclAlreadyExistsException'); + $this->expectException('Symfony\Component\Security\Acl\Exception\AclAlreadyExistsException'); $this->getAclProvider()->createAcl($this->getAclObjectIdentity(1)); } @@ -109,9 +109,9 @@ class MutableAclProviderTest extends AclTestCase public function testUpdateAclInvalidAcl() { - $acl = $this->getMock('Symfony\Component\Security\Acl\Model\MutableAclInterface'); + $acl = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\MutableAclInterface')->getMock(); - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->getAclProvider()->updateAcl($acl); } diff --git a/Tests/Service/SchemaLocatorTest.php b/Tests/Service/SchemaLocatorTest.php new file mode 100644 index 0000000..d843b7d --- /dev/null +++ b/Tests/Service/SchemaLocatorTest.php @@ -0,0 +1,97 @@ + [ + 'directory' => [ + 'schema.xml' => 'Schema from configuration' + ] + ], + ]; + $this->root = vfsStream::setup('projectDir'); + vfsStream::create($pathStructure); + + $this->kernelMock = $this->getMockBuilder(Kernel::class)->disableOriginalConstructor()-> getMock(); + $this->kernelMock->method('getProjectDir')->willReturn($this->root->url()); + + $this->bundleMock = new FakeBundle(); + + $this->configuration['paths']['schemaDir'] = vfsStream::url('projectDir/configuration/directory'); + $this->fileLocator = new FileLocator( + [ + __DIR__ . '/../Fixtures', + ] + ); + } + + public function testLocateFromBundle() + { + + $locator = new SchemaLocator($this->fileLocator, $this->configuration); + $files = $locator->locateFromBundle($this->bundleMock); + + $this->assertCount(1, $files); + $this->assertTrue(isset($files[__DIR__ . '/../Fixtures/FakeBundle/Resources/config/bundle.schema.xml'])); + $this->assertEquals('bundle.schema.xml', $files[__DIR__ . '/../Fixtures/FakeBundle/Resources/config/bundle.schema.xml'][1]->getFileName()); + + } + + public function testLocateFromBundlesAndConfiguration() + { + $locator = new SchemaLocator($this->fileLocator, $this->configuration); + $files = $locator->locateFromBundlesAndConfiguration( + [$this->bundleMock] + ); + + $this->assertCount(2, $files); + $this->assertTrue(isset($files[__DIR__ . '/../Fixtures/FakeBundle/Resources/config/bundle.schema.xml'])); + $this->assertEquals('bundle.schema.xml', $files[__DIR__ . '/../Fixtures/FakeBundle/Resources/config/bundle.schema.xml'][1]->getFileName()); + $this->assertTrue(isset($files['vfs://projectDir/configuration/directory/schema.xml'])); + $this->assertEquals('schema.xml', $files['vfs://projectDir/configuration/directory/schema.xml'][1]->getFileName()); + + } +} diff --git a/Tests/TestCase.php b/Tests/TestCase.php index cd12fec..f3bf8ea 100644 --- a/Tests/TestCase.php +++ b/Tests/TestCase.php @@ -10,6 +10,7 @@ namespace Propel\Bundle\PropelBundle\Tests; +use PHPUnit\Framework\TestCase as BaseTestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; @@ -17,7 +18,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; /** * TestCase */ -class TestCase extends \PHPUnit_Framework_TestCase +class TestCase extends BaseTestCase { public function getContainer() { diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php deleted file mode 100644 index 549b693..0000000 --- a/Tests/bootstrap.php +++ /dev/null @@ -1,7 +0,0 @@ - + bootstrap="vendor/autoload.php">