Skip to content

Commit

Permalink
Merge pull request #2788 from magento-earl-grey/MAGETWO-92929
Browse files Browse the repository at this point in the history
[earl] MAGETWO-92929: Declarative schema tests are located in inappropriate place
  • Loading branch information
cpartica authored Jul 17, 2018
2 parents 1d469f8 + bc16085 commit 91e10cd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Framework\Test\Unit\Setup;
namespace Magento\Framework\Setup\Test\Unit;

use Magento\Framework\DB\Ddl\Table;
use Magento\Framework\Setup\SchemaListenerDefinition\BooleanDefinition;
Expand All @@ -16,7 +17,7 @@
/**
* Unit test for schema listener.
*
* @package Magento\Framework\Test\Unit\Setup
* @package Magento\Framework\Setup\Test\Unit
*/
class SchemaListenerTest extends \PHPUnit\Framework\TestCase
{
Expand All @@ -30,7 +31,7 @@ class SchemaListenerTest extends \PHPUnit\Framework\TestCase
*/
private $objectManagerHelper;

protected function setUp()
protected function setUp() : void
{
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->model = $this->objectManagerHelper->getObject(
Expand All @@ -51,7 +52,7 @@ protected function setUp()
/**
* @return Table
*/
private function getCreateTableDDL($tableName)
private function getCreateTableDDL($tableName) : Table
{
$table = new Table();
$table->setName($tableName);
Expand Down Expand Up @@ -91,7 +92,7 @@ private function getCreateTableDDL($tableName)
);
}

public function testRenameTable()
public function testRenameTable() : void
{
$this->model->setModuleName('First_Module');
$this->model->createTable($this->getCreateTableDDL('old_table'));
Expand All @@ -101,15 +102,15 @@ public function testRenameTable()
self::assertArrayNotHasKey('old_table', $tables['First_Module']);
}

public function testDropIndex()
public function testDropIndex() : void
{
$this->model->setModuleName('First_Module');
$this->model->createTable($this->getCreateTableDDL('index_table'));
$this->model->dropIndex('index_table', 'INDEX_KEY', 'index');
self::assertTrue($this->model->getTables()['First_Module']['index_table']['indexes']['INDEX_KEY']['disabled']);
}

public function testCreateTable()
public function testCreateTable() : void
{
$this->model->setModuleName('First_Module');
$this->model->createTable($this->getCreateTableDDL('new_table'));
Expand All @@ -125,7 +126,7 @@ public function testCreateTable()
'nullable' => false,
'default' => 'CURRENT_TIMESTAMP',
'disabled' => false,
'onCreate' => NULL,
'onCreate' => null,
],
'integer' =>
[
Expand All @@ -135,9 +136,9 @@ public function testCreateTable()
'unsigned' => false,
'nullable' => false,
'identity' => true,
'default' => NULL,
'default' => null,
'disabled' => false,
'onCreate' => NULL,
'onCreate' => null,
],
'decimal' =>
[
Expand All @@ -147,9 +148,9 @@ public function testCreateTable()
'precision' => '25',
'unsigned' => false,
'nullable' => false,
'default' => NULL,
'default' => null,
'disabled' => false,
'onCreate' => NULL,
'onCreate' => null,
],
],
$tables['First_Module']['new_table']['columns']
Expand Down Expand Up @@ -201,7 +202,7 @@ public function testCreateTable()
);
}

public function testDropTable()
public function testDropTable() : void
{
$this->model->setModuleName('Old_Module');
$this->model->createTable($this->getCreateTableDDL('old_table'));
Expand All @@ -210,7 +211,7 @@ public function testDropTable()
self::assertTrue($this->model->getTables()['New_Module']['old_table']['disabled']);
}

public function testDropTableInSameModule()
public function testDropTableInSameModule() : void
{
$this->model->setModuleName('Old_Module');
$this->model->createTable($this->getCreateTableDDL('old_table'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Framework\Test\Unit\Setup;
namespace Magento\Framework\Setup\Test\Unit;

use Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Setup\SchemaListener;
Expand All @@ -14,7 +15,7 @@
/**
* Unit test for schema persistor.
*
* @package Magento\Framework\Test\Unit\Setup
* @package Magento\Framework\Setup\Test\Unit
*/
class SchemaPersistorTest extends \PHPUnit\Framework\TestCase
{
Expand All @@ -38,7 +39,7 @@ class SchemaPersistorTest extends \PHPUnit\Framework\TestCase
*/
private $xmlPersistor;

protected function setUp()
protected function setUp() : void
{
$this->componentRegistrarMock = $this->getMockBuilder(ComponentRegistrar::class)
->disableOriginalConstructor()
Expand All @@ -60,7 +61,7 @@ protected function setUp()
* @param array $tables
* @param string $expectedXML
*/
public function testPersist(array $tables, $expectedXML)
public function testPersist(array $tables, $expectedXML) : void
{
$moduleName = 'First_Module';
/** @var SchemaListener|\PHPUnit_Framework_MockObject_MockObject $schemaListenerMock */
Expand Down Expand Up @@ -88,7 +89,7 @@ public function testPersist(array $tables, $expectedXML)
*
* @return array
*/
public function schemaListenerTablesDataProvider()
public function schemaListenerTablesDataProvider() : array
{
return [
[
Expand Down Expand Up @@ -143,6 +144,7 @@ public function schemaListenerTablesDataProvider()
]
]
],
// @codingStandardsIgnoreStart
'XMLResult' => '<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
Expand All @@ -161,6 +163,7 @@ public function schemaListenerTablesDataProvider()
</index>
</table>
</schema>'
// @codingStandardsIgnoreEnd
]
];
}
Expand Down

0 comments on commit 91e10cd

Please sign in to comment.