Skip to content

Commit

Permalink
Fixed Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zrnik committed Jul 7, 2021
1 parent 23ba84a commit aa4f5b2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
10 changes: 10 additions & 0 deletions .github/config/integrationTestDatabase.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Hello, this file is used by integration tests
# in github action.

# If you want to use your own database settings
# on your local environment, please copy this file
# without the ".dist" ending and modify!

dsn: "mysql:dbname=mk_sql_test;host=127.0.0.1"
user: "root"
pass: "mk_sql_test"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
/.idea/
/vendor/
/docs/example.php
.github/config/integrationTestDatabase.neon
composer.lock

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"tracy/tracy": "^2",
"phpunit/phpunit": "^9",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12"
"phpstan/phpstan-phpunit": "^0.12",
"nette/neon": "^3"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions src/Queries/Tables/TableDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

class TableDescription
{
/** @var IQueryMaker */
public string $queryMakerClass = '';
/** @var string|IQueryMaker */
public string|IQueryMaker $queryMakerClass = '';

public bool $tableExists = false;

Expand Down
14 changes: 13 additions & 1 deletion tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Date: 02.09.2020 13:52
*/

use Nette\Neon\Neon;
use PHPUnit\Framework\TestCase;
use Zrnik\MkSQL\Column;
use Zrnik\MkSQL\Enum\DriverType;
Expand All @@ -27,7 +28,18 @@ class IntegrationTest extends TestCase
public function testIntegration(): void
{
// MySQL Integration:
$MySQL_PDO = new PDO("mysql:dbname=mk_sql_test;host=127.0.0.1", "root", "mk_sql_test");
$configFile = file_exists(__DIR__."/../.github/config/integrationTestDatabase.neon")
? __DIR__."/../.github/config/integrationTestDatabase.neon"
: __DIR__."/../.github/config/integrationTestDatabase.neon.dist";

$config = Neon::decode(strval(file_get_contents($configFile)));

$MySQL_PDO = new PDO(
$config["dsn"],
$config["user"],
$config["pass"]
);

$this->processTest($MySQL_PDO);

// SQLite Integration:
Expand Down

0 comments on commit aa4f5b2

Please sign in to comment.