@@ -90,6 +90,9 @@ |
||
| 90 | 90 | ); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | + /** |
|
| 94 | + * @param string $fileName |
|
| 95 | + */ |
|
| 93 | 96 | protected function getClassNameFromFile($fileName) |
| 94 | 97 | { |
| 95 | 98 | $parts = explode('_', pathinfo($fileName, PATHINFO_FILENAME), 2); |
@@ -179,7 +179,7 @@ |
||
| 179 | 179 | * @throws \InvalidArgumentException When trying to set |
| 180 | 180 | * |
| 181 | 181 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType |
| 182 | - * @return boolean |
|
| 182 | + * @return false|null |
|
| 183 | 183 | */ |
| 184 | 184 | protected function setReferences($contentType) |
| 185 | 185 | { |
@@ -393,8 +393,7 @@ |
||
| 393 | 393 | $ret[$key] = $this->referenceResolver->getReferenceValue($val); |
| 394 | 394 | } |
| 395 | 395 | } |
| 396 | - } |
|
| 397 | - else { |
|
| 396 | + } else { |
|
| 398 | 397 | $ret = $value; |
| 399 | 398 | |
| 400 | 399 | if ($this->referenceResolver->isReference($value)) { |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | // Authenticate the user |
| 30 | 30 | $this->loginUser(); |
| 31 | 31 | |
| 32 | - foreach(array('identifier', 'content_type_group', 'name_pattern', 'name', 'attributes') as $key) { |
|
| 32 | + foreach (array('identifier', 'content_type_group', 'name_pattern', 'name', 'attributes') as $key) { |
|
| 33 | 33 | if (!array_key_exists($key, $this->dsl)) { |
| 34 | 34 | throw new \Exception("The '$key' key is missing in a content type creation definition"); |
| 35 | 35 | } |
@@ -1,7 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | use Kaliop\eZMigrationBundle\API\MigrationInterface; |
| 4 | - |
|
| 5 | 4 | use Symfony\Component\DependencyInjection\ContainerInterface; |
| 6 | 5 | use Kaliop\eZMigrationBundle\API\Value\Migration; |
| 7 | 6 | use Kaliop\eZMigrationBundle\API\Value\MigrationDefinition; |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $this->dbHandler = $this->container->get('ezpublish.connection'); |
| 37 | 37 | |
| 38 | 38 | $this->activeBundles = array(); |
| 39 | - foreach($this->container->get('kernel')->getBundles() as $bundle) |
|
| 39 | + foreach ($this->container->get('kernel')->getBundles() as $bundle) |
|
| 40 | 40 | { |
| 41 | 41 | $this->activeBundles[$bundle->getName()] = $bundle->getPath(); |
| 42 | 42 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | // we need to decide of a random time to stamp existing migrations. We use 'now - 1 minute'... |
| 59 | 59 | $executionDate = time() - 60; |
| 60 | - foreach($toMigrate as $legacyMigration) { |
|
| 60 | + foreach ($toMigrate as $legacyMigration) { |
|
| 61 | 61 | $name = $legacyMigration['version']; |
| 62 | 62 | |
| 63 | 63 | $path = $this->getLegacyMigrationDefinition($legacyMigration['version'], $legacyMigration['bundle']); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | { |
| 105 | 105 | /** @var \Doctrine\DBAL\Schema\AbstractSchemaManager $sm */ |
| 106 | 106 | $sm = $this->dbHandler->getConnection()->getSchemaManager(); |
| 107 | - foreach($sm->listTables() as $table) { |
|
| 107 | + foreach ($sm->listTables() as $table) { |
|
| 108 | 108 | if ($table->getName() == $tableName) { |
| 109 | 109 | return true; |
| 110 | 110 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | return false; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - foreach($versionDefinitions as $key => $versionDefinition) { |
|
| 154 | + foreach ($versionDefinitions as $key => $versionDefinition) { |
|
| 155 | 155 | if (!in_array(pathinfo($versionDefinition, PATHINFO_EXTENSION), array('php', 'yml', 'sql'))) { |
| 156 | 156 | unset($versionDefinitions[$key]); |
| 157 | 157 | } |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | * @param MigrationStep[] $steps |
| 34 | 34 | * @param string $parsingError |
| 35 | 35 | */ |
| 36 | - function __construct($name, $path, $rawDefinition, $status = 0, array $steps=array(), $parsingError = null) |
|
| 36 | + function __construct($name, $path, $rawDefinition, $status = 0, array $steps = array(), $parsingError = null) |
|
| 37 | 37 | { |
| 38 | 38 | $this->name = $name; |
| 39 | 39 | $this->path = $path; |
@@ -15,9 +15,9 @@ discard block |
||
| 15 | 15 | * @param int $flags |
| 16 | 16 | * @param string $iterator_class |
| 17 | 17 | */ |
| 18 | - public function __construct ($input = array(), $flags = 0, $iterator_class = "ArrayIterator") |
|
| 18 | + public function __construct($input = array(), $flags = 0, $iterator_class = "ArrayIterator") |
|
| 19 | 19 | { |
| 20 | - foreach($input as $value) { |
|
| 20 | + foreach ($input as $value) { |
|
| 21 | 21 | if (!is_a($value, $this->allowedClass)) { |
| 22 | 22 | $this->throwInvalid($value); |
| 23 | 23 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * @param mixed $value |
| 29 | 29 | */ |
| 30 | - public function append ($value) |
|
| 30 | + public function append($value) |
|
| 31 | 31 | { |
| 32 | 32 | if (!is_a($value, $this->allowedClass)) { |
| 33 | 33 | $this->throwInvalid($value); |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * @param mixed $input |
| 39 | 39 | */ |
| 40 | - public function exchangeArray ($input) |
|
| 40 | + public function exchangeArray($input) |
|
| 41 | 41 | { |
| 42 | - foreach($input as $value) { |
|
| 42 | + foreach ($input as $value) { |
|
| 43 | 43 | if (!is_a($value, $this->allowedClass)) { |
| 44 | 44 | $this->throwInvalid($value); |
| 45 | 45 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @param mixed $index |
| 51 | 51 | * @param mixed $newval |
| 52 | 52 | */ |
| 53 | - public function offsetSet ($index , $newval) |
|
| 53 | + public function offsetSet($index, $newval) |
|
| 54 | 54 | { |
| 55 | 55 | if (!is_a($newval, $this->allowedClass)) { |
| 56 | 56 | $this->throwInvalid($newval); |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | $configuration = new Configuration(); |
| 23 | 23 | $config = $this->processConfiguration($configuration, $configs); |
| 24 | 24 | |
| 25 | - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
| 25 | + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
|
| 26 | 26 | $loader->load('services.yml'); |
| 27 | 27 | } |
| 28 | 28 | } |
@@ -28,27 +28,27 @@ discard block |
||
| 28 | 28 | public function setUp() { |
| 29 | 29 | parent::setUp(); |
| 30 | 30 | |
| 31 | - $this->configuration = new Configuration( $this->connection, new ConsoleOutput() ); |
|
| 31 | + $this->configuration = new Configuration($this->connection, new ConsoleOutput()); |
|
| 32 | 32 | |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function testGetConnection() { |
| 36 | 36 | $conn = $this->configuration->getConnection(); |
| 37 | 37 | |
| 38 | - $this->assertTrue( $conn instanceof Connection ); |
|
| 38 | + $this->assertTrue($conn instanceof Connection); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function testGetVersions() { |
| 42 | 42 | $version = $this->configuration->getVersions(); |
| 43 | 43 | |
| 44 | - $this->assertTrue( is_array($version ) ); |
|
| 44 | + $this->assertTrue(is_array($version)); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | public function testcreateVersionTableIfNeeded() |
| 48 | 48 | { |
| 49 | 49 | $result = $this->configuration->createVersionTableIfNeeded(); |
| 50 | 50 | |
| 51 | - $this->assertTrue( $result ); |
|
| 51 | + $this->assertTrue($result); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -61,19 +61,19 @@ discard block |
||
| 61 | 61 | $conn = $this->configuration->getConnection(); |
| 62 | 62 | |
| 63 | 63 | |
| 64 | - $time = date( 'YmdHis', time() ); |
|
| 64 | + $time = date('YmdHis', time()); |
|
| 65 | 65 | $bundle = 'testBundle'; |
| 66 | - $sql = sprintf( "INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle, $time ); |
|
| 66 | + $sql = sprintf("INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle, $time); |
|
| 67 | 67 | |
| 68 | - $conn->executeQuery( $sql ); |
|
| 68 | + $conn->executeQuery($sql); |
|
| 69 | 69 | |
| 70 | 70 | /** @var $versions array */ |
| 71 | - $versions = $this->configuration->getMigratedVersionsByBundle( $bundle ); |
|
| 71 | + $versions = $this->configuration->getMigratedVersionsByBundle($bundle); |
|
| 72 | 72 | |
| 73 | - $this->assertTrue( is_array( $versions ) ); |
|
| 74 | - $this->assertEquals( 1, count( $versions ) ); |
|
| 73 | + $this->assertTrue(is_array($versions)); |
|
| 74 | + $this->assertEquals(1, count($versions)); |
|
| 75 | 75 | |
| 76 | - $this->assertEquals( $time, $versions[0] ); |
|
| 76 | + $this->assertEquals($time, $versions[0]); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -86,23 +86,23 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | $conn = $this->configuration->getConnection(); |
| 88 | 88 | |
| 89 | - $time = date( 'YmdHis', time() - 3600 ); |
|
| 89 | + $time = date('YmdHis', time() - 3600); |
|
| 90 | 90 | $bundle = 'testBundle'; |
| 91 | 91 | |
| 92 | - $this->configuration->setVersions( array( $bundle => array() ) ); |
|
| 92 | + $this->configuration->setVersions(array($bundle => array())); |
|
| 93 | 93 | |
| 94 | - $sql = sprintf( "INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle, $time ); |
|
| 94 | + $sql = sprintf("INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle, $time); |
|
| 95 | 95 | |
| 96 | - $conn->executeQuery( $sql ); |
|
| 96 | + $conn->executeQuery($sql); |
|
| 97 | 97 | |
| 98 | - $time = date( 'YmdHis', time() ); |
|
| 99 | - $sql = sprintf( "INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle, $time ); |
|
| 98 | + $time = date('YmdHis', time()); |
|
| 99 | + $sql = sprintf("INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle, $time); |
|
| 100 | 100 | |
| 101 | - $conn->executeQuery( $sql ); |
|
| 101 | + $conn->executeQuery($sql); |
|
| 102 | 102 | |
| 103 | - $version = $this->configuration->getCurrentVersionByBundle( $bundle ); |
|
| 103 | + $version = $this->configuration->getCurrentVersionByBundle($bundle); |
|
| 104 | 104 | |
| 105 | - $this->assertEquals( (int)$time, $version ); |
|
| 105 | + $this->assertEquals((int)$time, $version); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -116,37 +116,37 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | $conn = $this->configuration->getConnection(); |
| 118 | 118 | |
| 119 | - $time = date( 'YmdHis', time() - 3600 ); |
|
| 119 | + $time = date('YmdHis', time() - 3600); |
|
| 120 | 120 | $bundle1 = 'testBundle'; |
| 121 | 121 | $bundle2 = 'testBundle2'; |
| 122 | 122 | |
| 123 | - $this->configuration->setVersions( array( $bundle1 => array(), $bundle2 => array() ) ); |
|
| 123 | + $this->configuration->setVersions(array($bundle1 => array(), $bundle2 => array())); |
|
| 124 | 124 | |
| 125 | - $sql = sprintf( "INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle1, $time ); |
|
| 125 | + $sql = sprintf("INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle1, $time); |
|
| 126 | 126 | |
| 127 | - $conn->executeQuery( $sql ); |
|
| 127 | + $conn->executeQuery($sql); |
|
| 128 | 128 | |
| 129 | - $sql = sprintf( "INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle2, $time ); |
|
| 129 | + $sql = sprintf("INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle2, $time); |
|
| 130 | 130 | |
| 131 | - $conn->executeQuery( $sql ); |
|
| 131 | + $conn->executeQuery($sql); |
|
| 132 | 132 | |
| 133 | - $time = date( 'YmdHis', time() ); |
|
| 134 | - $sql = sprintf( "INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle1, $time ); |
|
| 133 | + $time = date('YmdHis', time()); |
|
| 134 | + $sql = sprintf("INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle1, $time); |
|
| 135 | 135 | |
| 136 | - $conn->executeQuery( $sql ); |
|
| 136 | + $conn->executeQuery($sql); |
|
| 137 | 137 | |
| 138 | - $time2 = date( 'YmdHis', time() ); |
|
| 139 | - $sql = sprintf( "INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle2, $time2 ); |
|
| 138 | + $time2 = date('YmdHis', time()); |
|
| 139 | + $sql = sprintf("INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle2, $time2); |
|
| 140 | 140 | |
| 141 | - $conn->executeQuery( $sql ); |
|
| 141 | + $conn->executeQuery($sql); |
|
| 142 | 142 | |
| 143 | 143 | $versions = $this->configuration->getCurrentBundleVersions(); |
| 144 | 144 | |
| 145 | - $this->assertTrue( is_array( $versions ) ); |
|
| 146 | - $this->assertEquals( 2, count( $versions ) ); |
|
| 145 | + $this->assertTrue(is_array($versions)); |
|
| 146 | + $this->assertEquals(2, count($versions)); |
|
| 147 | 147 | |
| 148 | - $this->assertEquals( (int)$time, $versions[$bundle1] ); |
|
| 149 | - $this->assertEquals( (int)$time2, $versions[$bundle2] ); |
|
| 148 | + $this->assertEquals((int)$time, $versions[$bundle1]); |
|
| 149 | + $this->assertEquals((int)$time2, $versions[$bundle2]); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -158,46 +158,46 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | $conn = $this->configuration->getConnection(); |
| 160 | 160 | |
| 161 | - $time = date( 'YmdHis', time() - 3600 ); |
|
| 161 | + $time = date('YmdHis', time() - 3600); |
|
| 162 | 162 | $bundle1 = 'testBundle'; |
| 163 | 163 | $bundle2 = 'testBundle2'; |
| 164 | 164 | |
| 165 | - $this->configuration->setVersions( array( $bundle1 => array(), $bundle2 => array() ) ); |
|
| 165 | + $this->configuration->setVersions(array($bundle1 => array(), $bundle2 => array())); |
|
| 166 | 166 | |
| 167 | - $sql = sprintf( "INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle1, $time ); |
|
| 167 | + $sql = sprintf("INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle1, $time); |
|
| 168 | 168 | |
| 169 | - $conn->executeQuery( $sql ); |
|
| 169 | + $conn->executeQuery($sql); |
|
| 170 | 170 | |
| 171 | - $sql = sprintf( "INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle2, $time ); |
|
| 171 | + $sql = sprintf("INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle2, $time); |
|
| 172 | 172 | |
| 173 | - $conn->executeQuery( $sql ); |
|
| 173 | + $conn->executeQuery($sql); |
|
| 174 | 174 | |
| 175 | - $time1 = date( 'YmdHis', time() ); |
|
| 176 | - $sql = sprintf( "INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle1, $time1 ); |
|
| 175 | + $time1 = date('YmdHis', time()); |
|
| 176 | + $sql = sprintf("INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle1, $time1); |
|
| 177 | 177 | |
| 178 | - $conn->executeQuery( $sql ); |
|
| 178 | + $conn->executeQuery($sql); |
|
| 179 | 179 | |
| 180 | - $time2 = date( 'YmdHis', time() ); |
|
| 181 | - $sql = sprintf( "INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle2, $time2 ); |
|
| 180 | + $time2 = date('YmdHis', time()); |
|
| 181 | + $sql = sprintf("INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle2, $time2); |
|
| 182 | 182 | |
| 183 | - $conn->executeQuery( $sql ); |
|
| 183 | + $conn->executeQuery($sql); |
|
| 184 | 184 | |
| 185 | 185 | $versions = $this->configuration->getMigratedVersions(); |
| 186 | 186 | |
| 187 | - $this->assertTrue( is_array( $versions ) ); |
|
| 188 | - $this->assertEquals( 2, count( $versions ) ); |
|
| 189 | - $this->assertArrayHasKey( $bundle1, $versions ); |
|
| 190 | - $this->assertArrayHasKey( $bundle2, $versions ); |
|
| 187 | + $this->assertTrue(is_array($versions)); |
|
| 188 | + $this->assertEquals(2, count($versions)); |
|
| 189 | + $this->assertArrayHasKey($bundle1, $versions); |
|
| 190 | + $this->assertArrayHasKey($bundle2, $versions); |
|
| 191 | 191 | |
| 192 | - $this->assertTrue( is_array( $versions[$bundle1] ) ); |
|
| 193 | - $this->assertTrue( is_array( $versions[$bundle2] ) ); |
|
| 194 | - $this->assertEquals( 2, count( $versions[$bundle1] ) ); |
|
| 195 | - $this->assertEquals( 2, count( $versions[$bundle2] ) ); |
|
| 192 | + $this->assertTrue(is_array($versions[$bundle1])); |
|
| 193 | + $this->assertTrue(is_array($versions[$bundle2])); |
|
| 194 | + $this->assertEquals(2, count($versions[$bundle1])); |
|
| 195 | + $this->assertEquals(2, count($versions[$bundle2])); |
|
| 196 | 196 | |
| 197 | - $this->assertEquals( $time, $versions[$bundle1][0] ); |
|
| 198 | - $this->assertEquals( $time, $versions[$bundle2][0] ); |
|
| 199 | - $this->assertEquals( $time1, $versions[$bundle1][1] ); |
|
| 200 | - $this->assertEquals( $time2, $versions[$bundle2][1] ); |
|
| 197 | + $this->assertEquals($time, $versions[$bundle1][0]); |
|
| 198 | + $this->assertEquals($time, $versions[$bundle2][0]); |
|
| 199 | + $this->assertEquals($time1, $versions[$bundle1][1]); |
|
| 200 | + $this->assertEquals($time2, $versions[$bundle2][1]); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -209,10 +209,10 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | $conn = $this->configuration->getConnection(); |
| 211 | 211 | |
| 212 | - $time = date( 'YmdHis', time() - 3600 ); |
|
| 213 | - $time1 = date( 'YmdHis', time() ); |
|
| 214 | - $time2 = date( 'YmdHis', time() + 3600 ); |
|
| 215 | - $time3 = date( 'YmdHis', time() + 7200 ); |
|
| 212 | + $time = date('YmdHis', time() - 3600); |
|
| 213 | + $time1 = date('YmdHis', time()); |
|
| 214 | + $time2 = date('YmdHis', time() + 3600); |
|
| 215 | + $time3 = date('YmdHis', time() + 7200); |
|
| 216 | 216 | $bundle1 = 'testBundle'; |
| 217 | 217 | $bundle2 = 'testBundle2'; |
| 218 | 218 | |
@@ -229,35 +229,35 @@ discard block |
||
| 229 | 229 | ) |
| 230 | 230 | ); |
| 231 | 231 | |
| 232 | - $this->configuration->setVersions( $versions ); |
|
| 232 | + $this->configuration->setVersions($versions); |
|
| 233 | 233 | |
| 234 | - $sql = sprintf( "INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle1, $time ); |
|
| 234 | + $sql = sprintf("INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle1, $time); |
|
| 235 | 235 | |
| 236 | - $conn->executeQuery( $sql ); |
|
| 236 | + $conn->executeQuery($sql); |
|
| 237 | 237 | |
| 238 | - $sql = sprintf( "INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle2, $time ); |
|
| 238 | + $sql = sprintf("INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle2, $time); |
|
| 239 | 239 | |
| 240 | - $conn->executeQuery( $sql ); |
|
| 240 | + $conn->executeQuery($sql); |
|
| 241 | 241 | |
| 242 | - $sql = sprintf( "INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle1, $time1 ); |
|
| 242 | + $sql = sprintf("INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle1, $time1); |
|
| 243 | 243 | |
| 244 | - $conn->executeQuery( $sql ); |
|
| 244 | + $conn->executeQuery($sql); |
|
| 245 | 245 | |
| 246 | - $sql = sprintf( "INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle2, $time2 ); |
|
| 246 | + $sql = sprintf("INSERT INTO %s ( 'bundle', 'version' ) VALUES( '%s', '%s' )", $this->configuration->versionTableName, $bundle2, $time2); |
|
| 247 | 247 | |
| 248 | - $conn->executeQuery( $sql ); |
|
| 248 | + $conn->executeQuery($sql); |
|
| 249 | 249 | |
| 250 | 250 | $results = $this->configuration->migrationsToExecute(); |
| 251 | 251 | |
| 252 | - $this->assertTrue( is_array( $results ) ); |
|
| 253 | - $this->assertEquals( 2, count( $results ) ); |
|
| 254 | - $this->assertArrayHasKey( $bundle1, $results ); |
|
| 255 | - $this->assertArrayHasKey( $bundle2, $results ); |
|
| 252 | + $this->assertTrue(is_array($results)); |
|
| 253 | + $this->assertEquals(2, count($results)); |
|
| 254 | + $this->assertArrayHasKey($bundle1, $results); |
|
| 255 | + $this->assertArrayHasKey($bundle2, $results); |
|
| 256 | 256 | |
| 257 | - $this->assertEquals( 1, count( $results[$bundle1] ) ); |
|
| 258 | - $this->assertEquals( $time2, key( $results[$bundle1] ) ); |
|
| 259 | - $this->assertEquals( 1, count( $results[$bundle2] ) ); |
|
| 260 | - $this->assertEquals( $time3, key( $results[$bundle2] ) ); |
|
| 257 | + $this->assertEquals(1, count($results[$bundle1])); |
|
| 258 | + $this->assertEquals($time2, key($results[$bundle1])); |
|
| 259 | + $this->assertEquals(1, count($results[$bundle2])); |
|
| 260 | + $this->assertEquals($time3, key($results[$bundle2])); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -270,16 +270,16 @@ discard block |
||
| 270 | 270 | $bundle = 'testBundle'; |
| 271 | 271 | $version = '1'; |
| 272 | 272 | |
| 273 | - $versions = $this->configuration->getMigratedVersionsByBundle( $bundle ); |
|
| 274 | - $this->assertTrue( is_array( $versions ) ); |
|
| 275 | - $this->assertEquals( 0, count( $versions ) ); |
|
| 273 | + $versions = $this->configuration->getMigratedVersionsByBundle($bundle); |
|
| 274 | + $this->assertTrue(is_array($versions)); |
|
| 275 | + $this->assertEquals(0, count($versions)); |
|
| 276 | 276 | |
| 277 | - $this->configuration->markVersionMigrated( $bundle, $version ); |
|
| 278 | - $versions = $this->configuration->getMigratedVersionsByBundle( $bundle ); |
|
| 277 | + $this->configuration->markVersionMigrated($bundle, $version); |
|
| 278 | + $versions = $this->configuration->getMigratedVersionsByBundle($bundle); |
|
| 279 | 279 | |
| 280 | - $this->assertTrue( is_array( $versions ) ); |
|
| 281 | - $this->assertEquals( 1, count( $versions ) ); |
|
| 282 | - $this->assertEquals( $version, $versions[0] ); |
|
| 280 | + $this->assertTrue(is_array($versions)); |
|
| 281 | + $this->assertEquals(1, count($versions)); |
|
| 282 | + $this->assertEquals($version, $versions[0]); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
@@ -294,25 +294,25 @@ discard block |
||
| 294 | 294 | $version1 = '1'; |
| 295 | 295 | $version2 = '2'; |
| 296 | 296 | |
| 297 | - $versions = $this->configuration->getMigratedVersionsByBundle( $bundle ); |
|
| 298 | - $this->assertTrue( is_array( $versions ) ); |
|
| 299 | - $this->assertEquals( 0, count( $versions ) ); |
|
| 297 | + $versions = $this->configuration->getMigratedVersionsByBundle($bundle); |
|
| 298 | + $this->assertTrue(is_array($versions)); |
|
| 299 | + $this->assertEquals(0, count($versions)); |
|
| 300 | 300 | |
| 301 | - $this->configuration->markVersionMigrated( $bundle, $version1 ); |
|
| 302 | - $versions = $this->configuration->getMigratedVersionsByBundle( $bundle ); |
|
| 301 | + $this->configuration->markVersionMigrated($bundle, $version1); |
|
| 302 | + $versions = $this->configuration->getMigratedVersionsByBundle($bundle); |
|
| 303 | 303 | |
| 304 | - $this->assertTrue( is_array( $versions ) ); |
|
| 305 | - $this->assertEquals( 1, count( $versions ) ); |
|
| 306 | - $this->assertEquals( $version1, $versions[0] ); |
|
| 304 | + $this->assertTrue(is_array($versions)); |
|
| 305 | + $this->assertEquals(1, count($versions)); |
|
| 306 | + $this->assertEquals($version1, $versions[0]); |
|
| 307 | 307 | |
| 308 | - $this->configuration->markVersionMigrated( $bundle, $version2 ); |
|
| 309 | - $this->configuration->markVersionNotMigrated( $bundle, $version1 ); |
|
| 308 | + $this->configuration->markVersionMigrated($bundle, $version2); |
|
| 309 | + $this->configuration->markVersionNotMigrated($bundle, $version1); |
|
| 310 | 310 | |
| 311 | - $versions = $this->configuration->getMigratedVersionsByBundle( $bundle ); |
|
| 311 | + $versions = $this->configuration->getMigratedVersionsByBundle($bundle); |
|
| 312 | 312 | |
| 313 | - $this->assertTrue( is_array( $versions ) ); |
|
| 314 | - $this->assertEquals( 1, count( $versions ) ); |
|
| 315 | - $this->assertEquals( $version2, $versions[0] ); |
|
| 313 | + $this->assertTrue(is_array($versions)); |
|
| 314 | + $this->assertEquals(1, count($versions)); |
|
| 315 | + $this->assertEquals($version2, $versions[0]); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | /** |
@@ -322,21 +322,21 @@ discard block |
||
| 322 | 322 | public function testRegisterVersionFromDirectories() { |
| 323 | 323 | try { |
| 324 | 324 | $this->setupVfsStructure(); |
| 325 | - } catch ( \Exception $e ) { |
|
| 326 | - var_dump( $e->getMessage() ); |
|
| 327 | - $this->markTestSkipped( "The VfsStream bundle is not installed." ); |
|
| 325 | + } catch (\Exception $e) { |
|
| 326 | + var_dump($e->getMessage()); |
|
| 327 | + $this->markTestSkipped("The VfsStream bundle is not installed."); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | $paths = array( |
| 331 | - 'bundle1' => array( vfsStream::url( 'bundles/bundle1/MigrationVersions' ) ), |
|
| 332 | - 'bundle2' => array( vfsStream::url( 'bundles/bundle2/MigrationVersions' ) ) |
|
| 331 | + 'bundle1' => array(vfsStream::url('bundles/bundle1/MigrationVersions')), |
|
| 332 | + 'bundle2' => array(vfsStream::url('bundles/bundle2/MigrationVersions')) |
|
| 333 | 333 | ); |
| 334 | 334 | |
| 335 | 335 | $this->configuration->createVersionTableIfNeeded(); |
| 336 | 336 | |
| 337 | - $versions = $this->configuration->registerVersionFromDirectories( $paths ); |
|
| 337 | + $versions = $this->configuration->registerVersionFromDirectories($paths); |
|
| 338 | 338 | |
| 339 | - $this->markTestSkipped( "FIXME: figure out a way to test this" ); |
|
| 339 | + $this->markTestSkipped("FIXME: figure out a way to test this"); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | /** |
@@ -344,9 +344,9 @@ discard block |
||
| 344 | 344 | */ |
| 345 | 345 | public function testCheckDuplicateVersion() |
| 346 | 346 | { |
| 347 | - $this->configuration->setVersions( array( 'testBundle' => array( '1' ) ) ); |
|
| 347 | + $this->configuration->setVersions(array('testBundle' => array('1'))); |
|
| 348 | 348 | |
| 349 | - $this->configuration->checkDuplicateVersion( 'testBundle', '1' ); |
|
| 349 | + $this->configuration->checkDuplicateVersion('testBundle', '1'); |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
@@ -356,11 +356,11 @@ discard block |
||
| 356 | 356 | |
| 357 | 357 | try { |
| 358 | 358 | $this->setupVfsStructure(); |
| 359 | - } catch( \Exception $e ) { |
|
| 360 | - $this->markTestSkipped( 'Problem with VfsStream.' ); |
|
| 359 | + } catch (\Exception $e) { |
|
| 360 | + $this->markTestSkipped('Problem with VfsStream.'); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - $path = vfsStream::url( 'bundles/bundle1/MigrationVersions/Version20010101010101.php' ); |
|
| 363 | + $path = vfsStream::url('bundles/bundle1/MigrationVersions/Version20010101010101.php'); |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | /** |
@@ -374,21 +374,21 @@ discard block |
||
| 374 | 374 | $structure = array( |
| 375 | 375 | 'bundle1' => array( |
| 376 | 376 | 'MigrationVersions' => array( |
| 377 | - 'Version20010101010101.php' => '<?php namespace MigrationVersions\bundle1;'."\n" . $this->dummyVersionContent . "\n?>", |
|
| 378 | - 'Version20010101010102.php' => '<?php namespace MigrationVersions\bundle1;'."\n" . $this->dummyVersionContent . "\n?>", |
|
| 377 | + 'Version20010101010101.php' => '<?php namespace MigrationVersions\bundle1;' . "\n" . $this->dummyVersionContent . "\n?>", |
|
| 378 | + 'Version20010101010102.php' => '<?php namespace MigrationVersions\bundle1;' . "\n" . $this->dummyVersionContent . "\n?>", |
|
| 379 | 379 | ) |
| 380 | 380 | ), |
| 381 | 381 | 'bundle2' => array( |
| 382 | 382 | 'MigrationVersions' => array( |
| 383 | - 'Version20010101010103.php' => '<?php namespace MigrationVersions\bundle2;'."\n" . $this->dummyVersionContent . "\n?>", |
|
| 383 | + 'Version20010101010103.php' => '<?php namespace MigrationVersions\bundle2;' . "\n" . $this->dummyVersionContent . "\n?>", |
|
| 384 | 384 | ) |
| 385 | 385 | ) |
| 386 | 386 | ); |
| 387 | - } catch( Exception $e ) { |
|
| 388 | - throw new \Exception( $e->getMessage() ); |
|
| 387 | + } catch (Exception $e) { |
|
| 388 | + throw new \Exception($e->getMessage()); |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | - $this->root = vfsStream::setup( 'bundles', null, $structure ); |
|
| 391 | + $this->root = vfsStream::setup('bundles', null, $structure); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | /** |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | $migrationsService = $this->getMigrationService(); |
| 43 | 43 | |
| 44 | - $migrationDefinitions = $migrationsService->getMigrationsDefinitions($input->getOption('path')) ; |
|
| 44 | + $migrationDefinitions = $migrationsService->getMigrationsDefinitions($input->getOption('path')); |
|
| 45 | 45 | $migrations = $migrationsService->getMigrations(); |
| 46 | 46 | |
| 47 | 47 | if (!count($migrationDefinitions) && !count($migrations)) { |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | // create a unique ist of all migrations (coming from db) and definitions (coming from disk) |
| 53 | 53 | $index = array(); |
| 54 | - foreach($migrationDefinitions as $migrationDefinition) { |
|
| 54 | + foreach ($migrationDefinitions as $migrationDefinition) { |
|
| 55 | 55 | $index[$migrationDefinition->name] = array('definition' => $migrationDefinition); |
| 56 | 56 | } |
| 57 | - foreach($migrations as $migration) { |
|
| 57 | + foreach ($migrations as $migration) { |
|
| 58 | 58 | if (isset($index[$migration->name])) { |
| 59 | 59 | $index[$migration->name]['migration'] = $migration; |
| 60 | 60 | } else { |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | $index[$migration->name]['definition'] = reset($migrationDefinitionCollection); |
| 70 | 70 | } |
| 71 | - } catch(\Exception $e) { |
|
| 71 | + } catch (\Exception $e) { |
|
| 72 | 72 | /// @todo one day we should be able to limit the kind of exceptions we have to catch here... |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | $data = array(); |
| 82 | 82 | $i = 1; |
| 83 | - foreach($index as $name => $value) { |
|
| 83 | + foreach ($index as $name => $value) { |
|
| 84 | 84 | if (!isset($value['migration'])) { |
| 85 | 85 | $migrationDefinition = $migrationsService->parseMigrationDefinition($value['definition']); |
| 86 | 86 | $notes = ''; |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | $this->dsl['user_id'] = array($this->dsl['user_id']); |
| 133 | 133 | } |
| 134 | 134 | foreach ($this->dsl['user_id'] as $id) { |
| 135 | - array_push($usersToDelete,$userService->loadUser($id)); |
|
| 135 | + array_push($usersToDelete, $userService->loadUser($id)); |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | if (isset($this->dsl['email'])) { |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $this->dsl['email'] = array($this->dsl['email']); |
| 141 | 141 | } |
| 142 | 142 | foreach ($this->dsl['email'] as $email) { |
| 143 | - $usersToDelete = array_merge($usersToDelete,$userService->loadUsersByEmail($email)); |
|
| 143 | + $usersToDelete = array_merge($usersToDelete, $userService->loadUsersByEmail($email)); |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | if (isset($this->dsl['username'])) { |
@@ -148,11 +148,11 @@ discard block |
||
| 148 | 148 | $this->dsl['username'] = array($this->dsl['username']); |
| 149 | 149 | } |
| 150 | 150 | foreach ($this->dsl['username'] as $username) { |
| 151 | - array_push($usersToDelete,$userService->loadUserByLogin($username)); |
|
| 151 | + array_push($usersToDelete, $userService->loadUserByLogin($username)); |
|
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - foreach($usersToDelete as $user){ |
|
| 155 | + foreach ($usersToDelete as $user) { |
|
| 156 | 156 | $userService->deleteUser($user); |
| 157 | 157 | } |
| 158 | 158 | } |