Skip to content

Commit

Permalink
tests: remove dependency on dibi_test database name
Browse files Browse the repository at this point in the history
  • Loading branch information
milo committed Nov 22, 2022
1 parent cab1c5b commit 5d11aeb
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
8 changes: 7 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ cache:

clone_folder: c:\projects\dibi

environment:
MYSQL_PWD: Password12!

services:
- mssql2012sp1
# - mssql2014
- mysql

init:
- SET PATH=c:\php;%PATH%
- SET PATH=c:\php;c:\Program Files\MySQL\MySQL Server 5.7\bin;%PATH%
- SET ANSICON=121x90 (121x90)

install:
Expand All @@ -32,6 +35,9 @@ install:
- IF %PHP%==1 curl https://download.microsoft.com/download/2/4/3/24375141-E08D-4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine_X64.exe --output AccessDatabaseEngine_X64.exe
- cmd /c start /wait AccessDatabaseEngine_X64.exe /passive

# Create MySQL database
- mysql --user=root -e "CREATE DATABASE dibi_test"

# Install Nette Tester
- cd c:\projects\dibi
- appveyor DownloadFile https://getcomposer.org/composer.phar
Expand Down
3 changes: 2 additions & 1 deletion tests/databases.appveyor.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ driver = mysqli
host = 127.0.0.1
username = root
password = "Password12!"
database = dibi_test
charset = utf8
system = mysql

[mysql pdo]
driver = pdo
dsn = "mysql:host=127.0.0.1"
dsn = "mysql:host=127.0.0.1;dbname=dibi_test"
username = root
password = "Password12!"
system = mysql
Expand Down
3 changes: 2 additions & 1 deletion tests/databases.sample.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ driver = mysqli
host = 127.0.0.1
username = root
password =
database = dibi_test
charset = utf8
system = mysql

[mysql pdo]
driver = pdo
dsn = "mysql:host=127.0.0.1"
dsn = "mysql:host=127.0.0.1;dbname=dibi_test"
username = root
password =
system = mysql
Expand Down
9 changes: 3 additions & 6 deletions tests/dibi/data/mysql.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
DROP DATABASE IF EXISTS dibi_test;
CREATE DATABASE dibi_test;
USE dibi_test;

DROP TABLE IF EXISTS `orders`;
DROP TABLE IF EXISTS `products`;
DROP TABLE IF EXISTS `customers`;

CREATE TABLE `products` (
`product_id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(100) NOT NULL,
Expand All @@ -15,7 +14,6 @@ INSERT INTO `products` (`product_id`, `title`) VALUES
(3, 'Computer'),
(2, 'Table');

DROP TABLE IF EXISTS `customers`;
CREATE TABLE `customers` (
`customer_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
Expand All @@ -30,7 +28,6 @@ INSERT INTO `customers` (`customer_id`, `name`) VALUES
(5, 'Kryten'),
(6, 'Kristine Kochanski');

DROP TABLE IF EXISTS `orders`;
CREATE TABLE `orders` (
`order_id` int(11) NOT NULL AUTO_INCREMENT,
`customer_id` int(11) NOT NULL,
Expand Down
11 changes: 5 additions & 6 deletions tests/dibi/meta.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ try {
Tester\Environment::skip($e->getMessage());
}

if ($config['system'] !== 'sqlsrv') {
Assert::same(3, count($meta->getTables()));
$names = $meta->getTableNames();
sort($names);
Assert::equal(['customers', 'orders', 'products'], $names);
}
$tableNames = $meta->getTableNames();
Assert::true(in_array('customers', $tableNames, true));
Assert::true(in_array('orders', $tableNames, true));
Assert::true(in_array('products', $tableNames, true));


Assert::false($meta->hasTable('xxxx'));

Expand Down
1 change: 0 additions & 1 deletion tests/dibi/mysql.time.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ require __DIR__ . '/bootstrap.php';

$conn = new Dibi\Connection($config);

$conn->query('USE dibi_test');
$conn->query('DROP TABLE IF EXISTS timetest');
$conn->query('CREATE TABLE timetest (col TIME NOT NULL) ENGINE=InnoDB');
$conn->query('INSERT INTO timetest VALUES ("12:30:40")');
Expand Down

0 comments on commit 5d11aeb

Please sign in to comment.