diff --git a/bundle/Command/Gateway.php b/bundle/Command/Gateway.php
index 247d878e..ad67a674 100644
--- a/bundle/Command/Gateway.php
+++ b/bundle/Command/Gateway.php
@@ -45,6 +45,11 @@ public function getContentTypeIds($contentTypeIdentifiers)
return $result;
}
+ /**
+ * @param $dryRun
+ * @param OutputInterface $output
+ * @return int Number of field definitions which was converted
+ */
public function convertFieldDefinitions($dryRun, OutputInterface $output)
{
$query = $this->dbal->createQueryBuilder();
@@ -85,6 +90,7 @@ public function convertFieldDefinitions($dryRun, OutputInterface $output)
}
$output->writeln("Converted $count ezxmltext field definitions to ezrichtext");
+ return $count;
}
public function getRowCountOfContentObjectAttributes($datatypeString, $contentId)
diff --git a/phpunit-integration-legacy-empty-db.xml b/phpunit-integration-legacy-empty-db.xml
new file mode 100644
index 00000000..18c3a842
--- /dev/null
+++ b/phpunit-integration-legacy-empty-db.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+ ./tests/bundle/Command/
+
+
+
+
+ ./bundle
+ ./lib
+ ./vendor
+
+
+
diff --git a/tests/bundle/Command/BaseTest.php b/tests/bundle/Command/BaseTest.php
new file mode 100644
index 00000000..5aa65f80
--- /dev/null
+++ b/tests/bundle/Command/BaseTest.php
@@ -0,0 +1,84 @@
+getSetupFactory()->getDatabaseHandler();
+
+ foreach ($data as $table => $rows) {
+ // Check that at least one row exists
+ if (!isset($rows[0])) {
+ continue;
+ }
+
+ $q = $db->createInsertQuery();
+ $q->insertInto($db->quoteIdentifier($table));
+
+ // Contains the bound parameters
+ $values = array();
+
+ // Binding the parameters
+ foreach ($rows[0] as $col => $val) {
+ $q->set(
+ $db->quoteIdentifier($col),
+ $q->bindParam($values[$col])
+ );
+ }
+
+ $stmt = $q->prepare();
+
+ foreach ($rows as $row) {
+ try {
+ // This CANNOT be replaced by:
+ // $values = $row
+ // each $values[$col] is a PHP reference which should be
+ // kept for parameters binding to work
+ foreach ($row as $col => $val) {
+ $values[$col] = $val;
+ }
+
+ $stmt->execute();
+ } catch (Exception $e) {
+ echo "$table ( ", implode(', ', $row), " )\n";
+ throw $e;
+ }
+ }
+ }
+
+ $this->resetSequences();
+ }
+
+ public function resetSequences()
+ {
+ switch ($this->getDB()) {
+ case 'pgsql':
+ // Update PostgreSQL sequences
+ $handler = $this->getSetupFactory()->getDatabaseHandler();
+
+ $queries = array_filter(preg_split('(;\\s*$)m',
+ file_get_contents(__DIR__ . '/_fixtures/setval.pgsql.sql')));
+ foreach ($queries as $query) {
+ $handler->exec($query);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/bundle/Command/GatewayTest.php b/tests/bundle/Command/GatewayTest.php
new file mode 100644
index 00000000..8ecd1eb6
--- /dev/null
+++ b/tests/bundle/Command/GatewayTest.php
@@ -0,0 +1,510 @@
+getSetupFactory()->resetDB();
+ }
+
+ public function getContentTypeIdsProvider()
+ {
+ return [
+ [
+ ['image', 'thumbnail'],
+ ['image' => 27, 'thumbnail' => 2],
+ ],
+ [
+ ['image'],
+ ['image' => 27],
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider getContentTypeIdsProvider
+ * @param $identifiers
+ * @param $expected
+ */
+ public function testGetContentTypeIds($identifiers, $expected)
+ {
+ //$this->getSetupFactory()->resetDB();
+ $this->insertDatabaseFixture(__DIR__ . '/_fixtures/contentclass.php');
+ $gatewayService = $this->getGatewayService();
+ $ids = $gatewayService->getContentTypeIds($identifiers);
+ $this->assertEquals($expected, $ids);
+ }
+
+ public function convertFieldDefinitionsProvider()
+ {
+ return [
+ [
+ true,
+ ],
+ [
+ false,
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider convertFieldDefinitionsProvider
+ * @param $dry boolean
+ */
+ public function testConvertFieldDefinitions($dry)
+ {
+ $outputStub = $this->createMock(OutputInterface::class);
+ $this->insertDatabaseFixture(__DIR__ . '/_fixtures/contentclass_attribute.php');
+ $gatewayService = $this->getGatewayService();
+ $count1 = $gatewayService->convertFieldDefinitions($dry, $outputStub);
+ $count2 = $gatewayService->convertFieldDefinitions($dry, $outputStub);
+
+ if ($dry) {
+ $this->assertEquals(2, $count1, 'Expected to find 2 field definitions subject for conversion');
+ $this->assertEquals(2, $count2, 'Expected to find 2 field definitions subject for conversion after running in dry mode');
+ } else {
+ $this->assertEquals(2, $count1, 'Expected to find 2 field definitions subject for conversion');
+ $this->assertEquals(0, $count2, 'Expected all field definitions to be converted');
+
+ }
+ }
+
+ public function getRowCountOfContentObjectAttributesProvider()
+ {
+ return [
+ [
+ 'ezxmltext',
+ 68,
+ 2,
+ ],
+ [
+ 'ezstring',
+ 68,
+ 3,
+ ],
+ [
+ 'foobar',
+ 68,
+ 0,
+ ],
+ [
+ 'ezxmltext',
+ 69,
+ 3,
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider getRowCountOfContentObjectAttributesProvider
+ * @param $datatypeString
+ * @param $contentId
+ * @param $expectedCount
+ */
+ public function testGetRowCountOfContentObjectAttributes($datatypeString, $contentId, $expectedCount)
+ {
+ $this->insertDatabaseFixture(__DIR__ . '/_fixtures/contentobject_attribute.php');
+
+ $gatewayService = $this->getGatewayService();
+ $count = $gatewayService->getRowCountOfContentObjectAttributes($datatypeString, $contentId);
+
+ $this->assertEquals($expectedCount, $count, 'Number of attributes does not match');
+
+ }
+
+ public function getFieldRowsProvider()
+ {
+ return [
+ [ //test $contentId
+ 'ezxmltext',
+ 68,
+ 0,
+ 100,
+ [
+ [
+ 'attribute_original_id' => '0',
+ 'contentclassattribute_id' => '183',
+ 'contentobject_id' => '68',
+ 'data_float' => '0.0',
+ 'data_int' => '1045487555',
+ 'data_text' => 'Content consumption is changing rapidly. An agile solution to distribute your content and empower your digital business model is key to success in every industry.',
+ 'data_type_string' => 'ezxmltext',
+ 'id' => '283',
+ 'language_code' => 'eng-GB',
+ 'language_id' => '2',
+ 'sort_key_int' => '0',
+ 'sort_key_string' => '',
+ 'version' => '1',
+ ],
+ [
+ 'attribute_original_id' => '0',
+ 'contentclassattribute_id' => '184',
+ 'contentobject_id' => '68',
+ 'data_float' => '0',
+ 'data_int' => '1045487555',
+ 'data_text' => 'eZ Publish Enterprise is the platform to make the omni-channel approach possible. A powerful presentation engine provides a multiplicity of websites and pages that display your content in a variety of renderings. A powerful API directly and simply integrates your content with any Web-enabled application on any device, including the iPad, iPhone or Android without ever interfering with or impacting the platform itself.',
+ 'data_type_string' => 'ezxmltext',
+ 'id' => '284',
+ 'language_code' => 'eng-GB',
+ 'language_id' => '2',
+ 'sort_key_int' => '0',
+ 'sort_key_string' => '',
+ 'version' => '1',
+ ],
+ ],
+ ],
+ [ // test $offset, $limit
+ 'ezxmltext',
+ null,
+ 0,
+ 1,
+ [
+ [
+ 'attribute_original_id' => '0',
+ 'contentclassattribute_id' => '183',
+ 'contentobject_id' => '68',
+ 'data_float' => '0.0',
+ 'data_int' => '1045487555',
+ 'data_text' => 'Content consumption is changing rapidly. An agile solution to distribute your content and empower your digital business model is key to success in every industry.',
+ 'data_type_string' => 'ezxmltext',
+ 'id' => '283',
+ 'language_code' => 'eng-GB',
+ 'language_id' => '2',
+ 'sort_key_int' => '0',
+ 'sort_key_string' => '',
+ 'version' => '1',
+ ],
+ ],
+ ],
+ [ // test $offset, $limit
+
+ 'ezxmltext',
+ null,
+ 1,
+ 1,
+ [
+ [
+ 'attribute_original_id' => '0',
+ 'contentclassattribute_id' => '184',
+ 'contentobject_id' => '68',
+ 'data_float' => '0',
+ 'data_int' => '1045487555',
+ 'data_text' => 'eZ Publish Enterprise is the platform to make the omni-channel approach possible. A powerful presentation engine provides a multiplicity of websites and pages that display your content in a variety of renderings. A powerful API directly and simply integrates your content with any Web-enabled application on any device, including the iPad, iPhone or Android without ever interfering with or impacting the platform itself.',
+ 'data_type_string' => 'ezxmltext',
+ 'id' => '284',
+ 'language_code' => 'eng-GB',
+ 'language_id' => '2',
+ 'sort_key_int' => '0',
+ 'sort_key_string' => '',
+ 'version' => '1',
+ ],
+ ],
+ ],
+ [ // test $offset, $limit
+
+ 'ezxmltext',
+ null,
+ 1,
+ 2,
+ [
+ [
+ 'attribute_original_id' => '0',
+ 'contentclassattribute_id' => '184',
+ 'contentobject_id' => '68',
+ 'data_float' => '0',
+ 'data_int' => '1045487555',
+ 'data_text' => 'eZ Publish Enterprise is the platform to make the omni-channel approach possible. A powerful presentation engine provides a multiplicity of websites and pages that display your content in a variety of renderings. A powerful API directly and simply integrates your content with any Web-enabled application on any device, including the iPad, iPhone or Android without ever interfering with or impacting the platform itself.',
+ 'data_type_string' => 'ezxmltext',
+ 'id' => '284',
+ 'language_code' => 'eng-GB',
+ 'language_id' => '2',
+ 'sort_key_int' => '0',
+ 'sort_key_string' => '',
+ 'version' => '1',
+ ],
+ [
+ 'attribute_original_id' => '0',
+ 'contentclassattribute_id' => '183',
+ 'contentobject_id' => '69',
+ 'data_float' => '0',
+ 'data_int' => null,
+ 'data_text' => 'Increasing the productivity of your content infrastructure, eZ Publish Enterprise provides you with powerful tools to create, automate and collaborate on content...',
+ 'data_type_string' => 'ezxmltext',
+ 'id' => '295',
+ 'language_code' => 'eng-GB',
+ 'language_id' => '2',
+ 'sort_key_int' => '0',
+ 'sort_key_string' => '',
+ 'version' => '1',
+ ],
+ ]
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider getFieldRowsProvider
+ * @param $datatypeString
+ * @param $contentId
+ * @param $offset
+ * @param $limit
+ * @param $expectedRows
+ */
+ public function testGetFieldRows($datatypeString, $contentId, $offset, $limit, $expectedRows)
+ {
+ $this->insertDatabaseFixture(__DIR__ . '/_fixtures/contentobject_attribute.php');
+
+ $gatewayService = $this->getGatewayService();
+ $statement = $gatewayService->getFieldRows($datatypeString, $contentId, $offset, $limit);
+ $index = 0;
+ while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
+ $this->assertLessThan(count($expectedRows), $index, 'Too many rows returned by getFieldRows');
+ $this->assertEquals($expectedRows[$index], $row, 'Result from getFieldRows() did not return expected result');
+ ++$index;
+ }
+ $this->assertEquals(count($expectedRows), $index, 'Too few rows returned by getFieldRows');
+ }
+
+ protected function getFieldRows($contentId)
+ {
+ $gatewayService = $this->getGatewayService();
+ $statement = $gatewayService->getFieldRows('ezxmltext', $contentId, 0, 100);
+ $rows = [];
+ while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
+ $rows[] = $row;
+ }
+
+ return $rows;
+ }
+
+ public function getAllFieldRows()
+ {
+ $query = $this->getDBAL()->createQueryBuilder();
+ $query->select('a.*')
+ ->from('ezcontentobject_attribute', 'a')
+ ->orderBy('a.id');
+
+ $statement = $query->execute();
+ while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
+ $rows[] = $row;
+ }
+
+ return $rows;
+ }
+
+
+ public function updateFieldRowProvider()
+ {
+ return [
+ [
+ true,
+ 283,
+ 1,
+ 'foobar',
+ ],
+ [
+ false,
+ 283,
+ 1,
+ 'foobar',
+ ],
+ [
+ true,
+ 295,
+ 1,
+ 'foobar',
+ ],
+ [
+ false,
+ 295,
+ 1,
+ 'foobar',
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider updateFieldRowProvider
+ * @param $dryRun
+ * @param $id
+ * @param $version
+ * @param $datatext
+ */
+ public function testUpdateFieldRow($dryRun, $id, $version, $datatext)
+ {
+ $this->insertDatabaseFixture(__DIR__ . '/_fixtures/contentobject_attribute.php');
+
+ $gatewayService = $this->getGatewayService();
+ $originalRows = $this->getAllFieldRows();
+
+ $gatewayService->updateFieldRow($dryRun, $id, $version, $datatext);
+
+ $updatedRows = $this->getAllFieldRows();
+ if ($dryRun) {
+ $this->assertEquals($originalRows, $updatedRows, 'Rows should not have been updated by updateFieldRow()');
+
+ } else {
+ foreach ($updatedRows as $key => $row) {
+ if ($row['id'] == $id && $row['version'] == $version) {
+ $this->assertEquals($datatext, $row['data_text'], 'data_text not updated correctly');
+ $this->assertEquals('ezrichtext', $row['data_type_string'], 'data_type_string not updated correctly');
+ } else {
+ $this->assertEquals($originalRows[$key], $row, 'Row should not have been updated by updateFieldRow()');
+ }
+ }
+ }
+ }
+
+ public function contentObjectAttributeExistsProvider()
+ {
+ return [
+ [
+ 68,
+ 283,
+ 1,
+ 'eng-GB',
+ true,
+ ],
+ [
+ 68,
+ 283,
+ 1,
+ 'nor-NO',
+ false,
+ ],
+ [
+ 69,
+ 295,
+ 1,
+ 'eng-GB',
+ true,
+ ],
+ [
+ 69,
+ 295,
+ 2,
+ 'eng-GB',
+ true,
+ ],
+ [
+ 69,
+ 295,
+ 3,
+ 'eng-GB',
+ false,
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider contentObjectAttributeExistsProvider
+ * @param $objectId
+ * @param $attributeId
+ * @param $version
+ * @param $language
+ * @param $expectedResult
+ */
+ public function testContentObjectAttributeExists($objectId, $attributeId, $version, $language, $expectedResult)
+ {
+ $this->insertDatabaseFixture(__DIR__ . '/_fixtures/contentobject_attribute.php');
+
+ $gatewayService = $this->getGatewayService();
+ $result = $gatewayService->contentObjectAttributeExists($objectId, $attributeId, $version, $language);
+
+ $this->assertEquals($expectedResult, $result, 'contentObjectAttributeExists() did not return expected value');
+ }
+
+ public function updateContentObjectAttributeProvider()
+ {
+ return [
+ [
+ 'foobar',
+ 68,
+ 283,
+ 1,
+ 'eng-GB',
+ ],
+ [
+ 'foobar',
+ 69,
+ 295,
+ 1,
+ 'eng-GB',
+ ],
+ [
+ 'foobar',
+ 69,
+ 295,
+ 2,
+ 'eng-GB',
+ ],
+ [
+ 'foobar',
+ 69,
+ 296,
+ 2,
+ 'nor-NO',
+ ],
+ ];
+
+ }
+
+ /**
+ * @dataProvider updateContentObjectAttributeProvider
+ * @param $xml
+ * @param $objectId
+ * @param $attributeId
+ * @param $version
+ * @param $language
+ */
+ public function testUpdateContentObjectAttribute($xml, $objectId, $attributeId, $version, $language)
+ {
+ $this->insertDatabaseFixture(__DIR__ . '/_fixtures/contentobject_attribute.php');
+
+ $gatewayService = $this->getGatewayService();
+ $originalRows = $this->getAllFieldRows();
+
+ $gatewayService->updateContentObjectAttribute($xml, $objectId, $attributeId, $version, $language);
+
+ $updatedRows = $this->getAllFieldRows();
+ foreach ($updatedRows as $key => $row) {
+ if ($row['contentobject_id'] == $objectId && $row['id'] == $attributeId && $row['version'] == $version && $row['language_code'] == $language ) {
+ $expectedRow = $originalRows[$key];
+ $expectedRow['data_text'] = $xml;
+ $this->assertEquals($expectedRow, $row, 'Field attribute not updated correctly');
+ } else {
+ $this->assertEquals($originalRows[$key], $row, 'Row should not have been updated by updateFieldRow()');
+ }
+ }
+ }
+
+ protected function getGatewayService()
+ {
+ return $this->getSetupFactory()->getServiceContainer()->get('ezxmltext.command.gateway');
+ }
+
+ public function getDB()
+ {
+ return $this->getSetupFactory()->getDB();
+ }
+
+ public function getDBAL()
+ {
+ $handler = $this->getSetupFactory()->getDatabaseHandler();
+ $connection = $handler->getConnection();
+ return $connection;
+ }
+}
\ No newline at end of file
diff --git a/tests/bundle/Command/_fixtures/contentclass.php b/tests/bundle/Command/_fixtures/contentclass.php
new file mode 100644
index 00000000..42982b5a
--- /dev/null
+++ b/tests/bundle/Command/_fixtures/contentclass.php
@@ -0,0 +1,67 @@
+ array(
+ 0 => array(
+ 'always_available' => 0,
+ 'contentobject_name' => '',
+ 'created' => 1024392098,
+ 'creator_id' => 14,
+ 'id' => 27,
+ 'identifier' => 'image',
+ 'initial_language_id' => 2,
+ 'is_container' => 0,
+ 'language_mask' => 3,
+ 'modified' => 1523277289,
+ 'modifier_id' => 14,
+ 'remote_id' => 'f6df12aa74e36230eb675f364fccd25a',
+ 'serialized_description_list' => 'a:1:{s:6:"eng-GB";s:0:"";}',
+ 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:5:"Image";s:16:"always-available";s:6:"eng-GB";}',
+ 'sort_field' => 1,
+ 'sort_order' => 1,
+ 'url_alias_name' => '',
+ 'version' => 0,
+ ),
+ 1 => array(
+ 'always_available' => 0,
+ 'contentobject_name' => '',
+ 'created' => 1024392098,
+ 'creator_id' => 14,
+ 'id' => 1,
+ 'identifier' => 'testarticle',
+ 'initial_language_id' => 2,
+ 'is_container' => 0,
+ 'language_mask' => 3,
+ 'modified' => 1523277289,
+ 'modifier_id' => 14,
+ 'remote_id' => 'f6df12aa74e36230eb675f364fccd25b',
+ 'serialized_description_list' => 'a:1:{s:6:"eng-GB";s:0:"";}',
+ 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:5:"Image";s:16:"always-available";s:6:"eng-GB";}',
+ 'sort_field' => 1,
+ 'sort_order' => 1,
+ 'url_alias_name' => '',
+ 'version' => 0,
+ ),
+ 2 => array(
+ 'always_available' => 0,
+ 'contentobject_name' => '',
+ 'created' => 1024392098,
+ 'creator_id' => 14,
+ 'id' => 2,
+ 'identifier' => 'thumbnail',
+ 'initial_language_id' => 2,
+ 'is_container' => 0,
+ 'language_mask' => 3,
+ 'modified' => 1523277289,
+ 'modifier_id' => 14,
+ 'remote_id' => 'f6df12aa74e36230eb675f364fccd25c',
+ 'serialized_description_list' => 'a:1:{s:6:"eng-GB";s:0:"";}',
+ 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:5:"Image";s:16:"always-available";s:6:"eng-GB";}',
+ 'sort_field' => 1,
+ 'sort_order' => 1,
+ 'url_alias_name' => '',
+ 'version' => 0,
+ ),
+ ),
+);
+
diff --git a/tests/bundle/Command/_fixtures/contentclass_attribute.php b/tests/bundle/Command/_fixtures/contentclass_attribute.php
new file mode 100644
index 00000000..a9e89f01
--- /dev/null
+++ b/tests/bundle/Command/_fixtures/contentclass_attribute.php
@@ -0,0 +1,93 @@
+ [
+ 0 => [
+ 'can_translate' => 1,
+ 'category' => '',
+ 'contentclass_id' => 1,
+ 'data_float1' => 0,
+ 'data_float2' => 0,
+ 'data_float3' => 0,
+ 'data_float4' => 0,
+ 'data_int1' => 5,
+ 'data_int2' => 0,
+ 'data_int3' => 0,
+ 'data_int4' => 0,
+ 'data_text1' => '', // Test schema out of date? should be data_text
+ 'data_text2' => '',
+ 'data_text3' => '',
+ 'data_text4' => '',
+ 'data_text5' => '',
+ 'data_type_string' => 'ezxmltext',
+ 'id' => 119,
+ 'identifier' => 'short_description',
+ 'is_information_collector' => 0,
+ 'is_required' => 0,
+ 'is_searchable' => 1,
+ 'placement' => 3,
+ 'serialized_data_text' => 'a:2:{s:6:"eng-GB";s:0:"";s:16:"always-available";s:6:"eng-GB";}',
+ 'serialized_description_list' => 'a:2:{s:6:"eng-GB";s:0:"";s:16:"always-available";s:6:"eng-GB";}',
+ 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:7:"Summary";s:16:"always-available";s:6:"eng-GB";}',
+ 'version' => 0,
+ ],
+ 1 => [
+ 'can_translate' => 1,
+ 'category' => '',
+ 'contentclass_id' => 1,
+ 'data_float1' => 0,
+ 'data_float2' => 0,
+ 'data_float3' => 0,
+ 'data_float4' => 0,
+ 'data_int1' => 20,
+ 'data_int2' => 0,
+ 'data_int3' => 0,
+ 'data_int4' => 0,
+ 'data_text1' => '',
+ 'data_text2' => '',
+ 'data_text3' => '',
+ 'data_text4' => '',
+ 'data_text5' => '',
+ 'data_type_string' => 'ezxmltext',
+ 'id' => 156,
+ 'identifier' => 'description',
+ 'is_information_collector' => 0,
+ 'is_required' => 0,
+ 'is_searchable' => 1,
+ 'placement' => 4,
+ 'serialized_data_text' => 'a:2:{s:6:"eng-GB";s:0:"";s:16:"always-available";s:6:"eng-GB";}',
+ 'serialized_description_list' => 'a:2:{s:6:"eng-GB";s:0:"";s:16:"always-available";s:6:"eng-GB";}',
+ 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:11:"Description";s:16:"always-available";s:6:"eng-GB";}',
+ 'version' => 0,
+ ],
+ 2 => [
+ 'can_translate' => 1,
+ 'category' => '',
+ 'contentclass_id' => 1,
+ 'data_float1' => 0,
+ 'data_float2' => 0,
+ 'data_float3' => 0,
+ 'data_float4' => 0,
+ 'data_int1' => 255,
+ 'data_int2' => 0,
+ 'data_int3' => 0,
+ 'data_int4' => 0,
+ 'data_text1' => 'Folder',
+ 'data_text2' => '',
+ 'data_text3' => '',
+ 'data_text4' => '',
+ 'data_text5' => '',
+ 'data_type_string' => 'ezstring',
+ 'id' => 4,
+ 'identifier' => 'name',
+ 'is_information_collector' => 0,
+ 'is_required' => 1,
+ 'is_searchable' => 1,
+ 'placement' => 1,
+ 'serialized_data_text' => 'a:2:{s:6:"eng-GB";s:0:"";s:16:"always-available";s:6:"eng-GB";}',
+ 'serialized_description_list' => 'a:2:{s:6:"eng-GB";s:0:"";s:16:"always-available";s:6:"eng-GB";}',
+ 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:4:"Name";s:16:"always-available";s:6:"eng-GB";}',
+ 'version' => 0,
+ ]
+ ],
+];
\ No newline at end of file
diff --git a/tests/bundle/Command/_fixtures/contentobject_attribute.php b/tests/bundle/Command/_fixtures/contentobject_attribute.php
new file mode 100644
index 00000000..8fde6af1
--- /dev/null
+++ b/tests/bundle/Command/_fixtures/contentobject_attribute.php
@@ -0,0 +1,157 @@
+ [
+ 0 => [
+ 'attribute_original_id' => 0,
+ 'contentclassattribute_id' => 181,
+ 'contentobject_id' => 68,
+ 'data_float' => 0,
+ 'data_int' => null,
+ 'data_text' => 'Deliver',
+ 'data_type_string' => 'ezstring',
+ 'id' => '281',
+ 'language_code' => 'eng-GB',
+ 'language_id' => '2',
+ 'sort_key_int' => 0,
+ 'sort_key_string' => 'deliver',
+ 'version' => 1,
+ ],
+ 1 => [
+ 'attribute_original_id' => 0,
+ 'contentclassattribute_id' => 182,
+ 'contentobject_id' => 68,
+ 'data_float' => 0,
+ 'data_int' => null,
+ 'data_text' => '',
+ 'data_type_string' => 'ezstring',
+ 'id' => '282',
+ 'language_code' => 'eng-GB',
+ 'language_id' => '2',
+ 'sort_key_int' => 0,
+ 'sort_key_string' => '',
+ 'version' => 1,
+ ],
+ 2 => [
+ 'attribute_original_id' => 0,
+ 'contentclassattribute_id' => 183,
+ 'contentobject_id' => 68,
+ 'data_float' => 0,
+ 'data_int' => 1045487555,
+ 'data_text' => 'Content consumption is changing rapidly. An agile solution to distribute your content and empower your digital business model is key to success in every industry.',
+ 'data_type_string' => 'ezxmltext',
+ 'id' => '283',
+ 'language_code' => 'eng-GB',
+ 'language_id' => '2',
+ 'sort_key_int' => 0,
+ 'sort_key_string' => '',
+ 'version' => 1,
+ ],
+ 3 => [
+ 'attribute_original_id' => 0,
+ 'contentclassattribute_id' => 184,
+ 'contentobject_id' => 68,
+ 'data_float' => 0,
+ 'data_int' => 1045487555,
+ 'data_text' => 'eZ Publish Enterprise is the platform to make the omni-channel approach possible. A powerful presentation engine provides a multiplicity of websites and pages that display your content in a variety of renderings. A powerful API directly and simply integrates your content with any Web-enabled application on any device, including the iPad, iPhone or Android without ever interfering with or impacting the platform itself.',
+ 'data_type_string' => 'ezxmltext',
+ 'id' => '284',
+ 'language_code' => 'eng-GB',
+ 'language_id' => '2',
+ 'sort_key_int' => 0,
+ 'sort_key_string' => '',
+ 'version' => 1,
+ ],
+ 4 => [
+ 'attribute_original_id' => 0,
+ 'contentclassattribute_id' => 185,
+ 'contentobject_id' => 68,
+ 'data_float' => 0,
+ 'data_int' => 1045487555,
+ 'data_text' => '',
+ 'data_type_string' => 'ezstring',
+ 'id' => '285',
+ 'language_code' => 'eng-GB',
+ 'language_id' => '2',
+ 'sort_key_int' => 0,
+ 'sort_key_string' => '',
+ 'version' => 1,
+ ],
+ 5 => [
+ 'attribute_original_id' => 0,
+ 'contentclassattribute_id' => 186,
+ 'contentobject_id' => 68,
+ 'data_float' => 0,
+ 'data_int' => null,
+ 'data_text' => '
+- MQ==
- NzIwMDAwLzEwMDAw
- NzIwMDAwLzEwMDAw
- Mg==
- QWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKQ==
- MjAxNDoxMToxMCAxNzo0MDoyMw==
- MTY4
- MQ==
- Nzcw
- Mjgx
',
+ 'data_type_string' => 'ezimage',
+ 'id' => '286',
+ 'language_code' => 'eng-GB',
+ 'language_id' => '2',
+ 'sort_key_int' => 0,
+ 'sort_key_string' => '',
+ 'version' => 1,
+ ],
+ 6 => [
+ 'attribute_original_id' => 0,
+ 'contentclassattribute_id' => 181,
+ 'contentobject_id' => 69,
+ 'data_float' => 0,
+ 'data_int' => null,
+ 'data_text' => 'Create',
+ 'data_type_string' => 'ezstring',
+ 'id' => '293',
+ 'language_code' => 'eng-GB',
+ 'language_id' => '2',
+ 'sort_key_int' => 0,
+ 'sort_key_string' => '',
+ 'version' => 1,
+ ],
+ 7 => [
+ 'attribute_original_id' => 0,
+ 'contentclassattribute_id' => 183,
+ 'contentobject_id' => 69,
+ 'data_float' => 0,
+ 'data_int' => null,
+ 'data_text' => 'Increasing the productivity of your content infrastructure, eZ Publish Enterprise provides you with powerful tools to create, automate and collaborate on content...',
+ 'data_type_string' => 'ezxmltext',
+ 'id' => '295',
+ 'language_code' => 'eng-GB',
+ 'language_id' => '2',
+ 'sort_key_int' => 0,
+ 'sort_key_string' => '',
+ 'version' => 1,
+ ],
+ 8 => [
+ 'attribute_original_id' => 0,
+ 'contentclassattribute_id' => 183,
+ 'contentobject_id' => 69,
+ 'data_float' => 0,
+ 'data_int' => null,
+ 'data_text' => '',
+ 'data_type_string' => 'ezxmltext',
+ 'id' => '295',
+ 'language_code' => 'eng-GB',
+ 'language_id' => '2',
+ 'sort_key_int' => 0,
+ 'sort_key_string' => '',
+ 'version' => 2,
+ ],
+ 9 => [
+ 'attribute_original_id' => 0,
+ 'contentclassattribute_id' => 183,
+ 'contentobject_id' => 69,
+ 'data_float' => 0,
+ 'data_int' => null,
+ 'data_text' => '',
+ 'data_type_string' => 'ezxmltext',
+ 'id' => '296',
+ 'language_code' => 'nor-NO',
+ 'language_id' => '2',
+ 'sort_key_int' => 0,
+ 'sort_key_string' => '',
+ 'version' => 2,
+ ],
+ ],
+];
\ No newline at end of file
diff --git a/tests/bundle/Command/_fixtures/setval.pgsql.sql b/tests/bundle/Command/_fixtures/setval.pgsql.sql
new file mode 100644
index 00000000..52700135
--- /dev/null
+++ b/tests/bundle/Command/_fixtures/setval.pgsql.sql
@@ -0,0 +1,30 @@
+SELECT setval('ezcobj_state_group_id_seq',max(id)) FROM ezcobj_state_group;
+SELECT setval('ezcobj_state_id_seq',max(id)) FROM ezcobj_state;
+SELECT setval('ezcontentclass_attribute_id_seq',max(id)) FROM ezcontentclass_attribute;
+SELECT setval('ezcontentclass_id_seq',max(id)) FROM ezcontentclass;
+SELECT setval('ezcontentclassgroup_id_seq',max(id)) FROM ezcontentclassgroup;
+SELECT setval('ezcontentobject_attribute_id_seq',max(id)) FROM ezcontentobject_attribute;
+SELECT setval('ezcontentobject_link_id_seq',max(id)) FROM ezcontentobject_link;
+SELECT setval('ezcontentobject_id_seq',max(id)) FROM ezcontentobject;
+SELECT setval('ezcontentobject_tree_node_id_seq',max(node_id)) FROM ezcontentobject_tree;
+SELECT setval('ezcontentobject_version_id_seq',max(id)) FROM ezcontentobject_version;
+SELECT setval('ezimagefile_id_seq',max(id)) FROM ezimagefile;
+SELECT setval('ezkeyword_attribute_link_id_seq',max(id)) FROM ezkeyword_attribute_link;
+SELECT setval('ezkeyword_id_seq',max(id)) FROM ezkeyword;
+SELECT setval('eznode_assignment_id_seq',max(id)) FROM eznode_assignment;
+SELECT setval('ezpolicy_limitation_id_seq',max(id)) FROM ezpolicy_limitation;
+SELECT setval('ezpolicy_limitation_value_id_seq',max(id)) FROM ezpolicy_limitation_value;
+SELECT setval('ezpolicy_id_seq',max(id)) FROM ezpolicy;
+SELECT setval('ezrole_id_seq',max(id)) FROM ezrole;
+SELECT setval('ezsearch_object_word_link_id_seq',max(id)) FROM ezsearch_object_word_link;
+SELECT setval('ezsearch_word_id_seq',max(id)) FROM ezsearch_word;
+SELECT setval('ezsection_id_seq',max(id)) FROM ezsection;
+SELECT setval('ezurl_id_seq',max(id)) FROM ezurl;
+SELECT setval('ezurlalias_ml_incr_id_seq',max(id)) FROM ezurlalias_ml_incr;
+SELECT setval('ezurlalias_id_seq',max(id)) FROM ezurlalias;
+SELECT setval('ezurlwildcard_id_seq',max(id)) FROM ezurlwildcard;
+SELECT setval('ezuser_accountkey_id_seq',max(id)) FROM ezuser_accountkey;
+SELECT setval('ezuser_role_id_seq',max(id)) FROM ezuser_role;
+SELECT setval('ezcontentbrowsebookmark_id_seq',max(id)) FROM ezcontentbrowsebookmark;
+SELECT setval('eznotification_id_seq',max(id)) FROM eznotification;
+SELECT setval('ezpreferences_id_seq',max(id)) FROM ezpreferences;
diff --git a/tests/lib/SetupFactory/LegacyEmptyDBSetupFactory.php b/tests/lib/SetupFactory/LegacyEmptyDBSetupFactory.php
new file mode 100644
index 00000000..0c4cb646
--- /dev/null
+++ b/tests/lib/SetupFactory/LegacyEmptyDBSetupFactory.php
@@ -0,0 +1,60 @@
+load('storage_engines/legacy/external_storage_gateways.yml');
+ $loader->load('storage_engines/legacy/field_value_converters.yml');
+ $loader->load('fieldtype_external_storages.yml');
+ $loader->load('fieldtypes.yml');
+ $loader->load('indexable_fieldtypes.yml');
+ $loader->load('../../bundle/Resources/config/services.yml');
+ }
+
+ public function getDatabaseHandler()
+ {
+ return parent::getDatabaseHandler();
+ }
+
+ public function getInitialData()
+ {
+ $data = parent::getInitialData();
+ $tables = [];
+ // just get the table names in the dump, so that insertData() will truncate them
+ foreach (array_reverse(array_keys($data)) as $table) {
+ $tables[$table] = [];
+ }
+
+ return $tables;
+ }
+
+ public function resetDB()
+ {
+ $this->getRepository(true);
+ }
+}