Skip to content

Commit 30dbc89

Browse files
milodg
authored andcommitted
tests: remove dependency on dibi_test database name
1 parent 6b99dd7 commit 30dbc89

6 files changed

Lines changed: 20 additions & 16 deletions

File tree

appveyor.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ cache:
55

66
clone_folder: c:\projects\dibi
77

8+
environment:
9+
MYSQL_PWD: Password12!
10+
811
services:
912
- mssql2012sp1
1013
# - mssql2014
1114
- mysql
1215

1316
init:
14-
- SET PATH=c:\php;%PATH%
17+
- SET PATH=c:\php;c:\Program Files\MySQL\MySQL Server 5.7\bin;%PATH%
1518
- SET ANSICON=121x90 (121x90)
1619

1720
install:
@@ -40,6 +43,10 @@ install:
4043
# Create databases.ini
4144
- copy tests\databases.appveyor.ini tests\databases.ini
4245

46+
before_test:
47+
# Create MySQL database
48+
- mysql --user=root -e "CREATE DATABASE dibi_test"
49+
4350
test_script:
4451
- vendor\bin\tester tests -s -p c:\php\php -c tests\php-win.ini
4552

tests/databases.appveyor.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ driver = mysqli
1313
host = 127.0.0.1
1414
username = root
1515
password = "Password12!"
16+
database = dibi_test
1617
charset = utf8
1718
system = mysql
1819

1920
[mysql pdo]
2021
driver = pdo
21-
dsn = "mysql:host=127.0.0.1"
22+
dsn = "mysql:host=127.0.0.1;dbname=dibi_test"
2223
username = root
2324
password = "Password12!"
2425
system = mysql

tests/databases.sample.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ driver = mysqli
1313
host = 127.0.0.1
1414
username = root
1515
password =
16+
database = dibi_test
1617
charset = utf8
1718
system = mysql
1819

1920
[mysql pdo]
2021
driver = pdo
21-
dsn = "mysql:host=127.0.0.1"
22+
dsn = "mysql:host=127.0.0.1;dbname=dibi_test"
2223
username = root
2324
password =
2425
system = mysql

tests/dibi/data/mysql.sql

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
DROP DATABASE IF EXISTS dibi_test;
2-
CREATE DATABASE dibi_test;
3-
USE dibi_test;
4-
1+
DROP TABLE IF EXISTS `orders`;
52
DROP TABLE IF EXISTS `products`;
3+
DROP TABLE IF EXISTS `customers`;
4+
65
CREATE TABLE `products` (
76
`product_id` int(11) NOT NULL AUTO_INCREMENT,
87
`title` varchar(100) NOT NULL,
@@ -15,7 +14,6 @@ INSERT INTO `products` (`product_id`, `title`) VALUES
1514
(3, 'Computer'),
1615
(2, 'Table');
1716

18-
DROP TABLE IF EXISTS `customers`;
1917
CREATE TABLE `customers` (
2018
`customer_id` int(11) NOT NULL AUTO_INCREMENT,
2119
`name` varchar(100) NOT NULL,
@@ -30,7 +28,6 @@ INSERT INTO `customers` (`customer_id`, `name`) VALUES
3028
(5, 'Kryten'),
3129
(6, 'Kristine Kochanski');
3230

33-
DROP TABLE IF EXISTS `orders`;
3431
CREATE TABLE `orders` (
3532
`order_id` int(11) NOT NULL AUTO_INCREMENT,
3633
`customer_id` int(11) NOT NULL,

tests/dibi/meta.phpt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ try {
1919
Tester\Environment::skip($e->getMessage());
2020
}
2121

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

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

tests/dibi/mysql.time.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ require __DIR__ . '/bootstrap.php';
1212

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

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

0 commit comments

Comments
 (0)