Skip to content

Commit

Permalink
Fix ImportTest
Browse files Browse the repository at this point in the history
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed Jun 9, 2020
1 parent b062eef commit e95e055
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions test/selenium/ImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,19 @@ protected function setUp(): void
public function testServerImport()
{
$this->doImport('server');
$result = $this->dbQuery("SHOW DATABASES LIKE 'test_import%'");
$this->assertGreaterThanOrEqual(2, $result->num_rows);
$this->dbQuery(
'SHOW DATABASES LIKE \'test_import%\'',
function () {
$this->assertEquals('test_import1', $this->getCellByTableClass('table_results', 1, 1));
$this->assertEquals('test_import2', $this->getCellByTableClass('table_results', 2, 1));
}
);

// clear db
$this->dbQuery('DROP DATABASE test_import1');
$this->dbQuery('DROP DATABASE test_import2');
$this->dbQuery(
'DROP DATABASE test_import1;'
. 'DROP DATABASE test_import2;'
);
}

/**
Expand All @@ -50,14 +57,19 @@ public function testServerImport()
*/
public function testDbImport()
{
$this->dbQuery('CREATE DATABASE ' . $this->database_name);
$this->dbQuery('CREATE DATABASE IF NOT EXISTS `' . $this->database_name . '`');
$this->navigateDatabase($this->database_name);

$this->doImport('db');

$this->dbQuery('USE ' . $this->database_name);
$result = $this->dbQuery('SHOW TABLES');
$this->assertEquals(1, $result->num_rows);
$this->dbQuery(
'USE `' . $this->database_name . '`;'
. 'SHOW TABLES FROM `' . $this->database_name . '`',
function () {
$this->assertTrue($this->isElementPresent('className', 'table_results'));
$this->assertEquals('test_table', $this->getCellByTableClass('table_results', 1, 1));
}
);
}

/**
Expand All @@ -70,18 +82,24 @@ public function testDbImport()
public function testTableImport()
{
// setup the db
$this->dbQuery('CREATE DATABASE ' . $this->database_name);
$this->dbQuery('USE ' . $this->database_name);
$this->dbQuery(
'CREATE TABLE IF NOT EXISTS `test_table` (`val` int(11) NOT NULL)'
'CREATE DATABASE IF NOT EXISTS `' . $this->database_name . '`;'
. 'USE `' . $this->database_name . '`;'
. 'CREATE TABLE IF NOT EXISTS `test_table` (`val` int(11) NOT NULL);'
);

$this->navigateTable('test_table');

$this->doImport('table');

$result = $this->dbQuery('SELECT * FROM test_table');
$this->assertEquals(2, $result->num_rows);
$this->dbQuery(
'SELECT * FROM `' . $this->database_name . '`.test_table',
function () {
$this->assertTrue($this->isElementPresent('className', 'table_results'));
$this->assertEquals('8', $this->getCellByTableClass('table_results', 1, 1));
$this->assertEquals('9', $this->getCellByTableClass('table_results', 2, 1));
}
);
}

/**
Expand Down

0 comments on commit e95e055

Please sign in to comment.