Skip to content

Commit

Permalink
CI - GH Actions: Increase PHPStan version, fix a load of errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
homersimpsons committed Mar 21, 2021
1 parent 0c96d3a commit 3b10344
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 28 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.2"
- "7.4"

services:
mysql:
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.2"
- "7.4"

services:
mysql:
Expand Down Expand Up @@ -137,8 +137,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.3"
- "7.4"
- "8.0"

services:
mysql:
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
}
],
"require": {
"php": ">=7.2.0",
"php": ">=7.4.0 || ^8.0",
"mouf/utils.common.conditioninterface": "~2.0",
"mouf/utils.value.value-interface": "~1.0",
"mouf/utils.common.paginable-interface": "~1.0",
"mouf/utils.common.sortable-interface": "~1.0",
"mouf/schema-analyzer": "~1.0",
"twig/twig": "^2.11 || ^3",
"greenlion/php-sql-parser": "^4.1.2",
"greenlion/php-sql-parser": "^4.3",
"doctrine/cache": "^1.5"
},
"require-dev": {
"phpunit/phpunit": "^7.5.10",
"phpunit/phpunit": "^9.5",
"satooshi/php-coveralls": "~1.0",
"doctrine/dbal": "~2.5",
"phpstan/phpstan": "^0.12.82"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,21 @@

use Mouf\Database\MagicQuery\Twig\SqlTwigEnvironmentFactory;
use PHPUnit\Framework\TestCase;
use Twig\Error\RuntimeError;

class SqlTwigEnvironmentFactoryTest extends TestCase
{
/**
*
*/
public function testIf()
{
$twig = SqlTwigEnvironmentFactory::getTwigEnvironment();
$sql = $twig->render('SELECT * FROM toto {% if id %}WHERE id = :id{% endif %}', ['id' => 12]);
$this->assertEquals('SELECT * FROM toto WHERE id = :id', $sql);
}

/**
* @expectedException \Twig\Error\RuntimeError
*/
public function testException()
{
$twig = SqlTwigEnvironmentFactory::getTwigEnvironment();
$this->expectException(RuntimeError::class);
$twig->render('SELECT * FROM toto WHERE id = {{ id }}', ['id' => 'hello']);
}
}
19 changes: 4 additions & 15 deletions tests/Mouf/Database/MagicQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,23 +210,19 @@ public function testStandardSelect()
$this->assertEquals($sql, self::simplifySql($magicQuery->build($sql)));
}

/**
* @expectedException \Mouf\Database\MagicQueryException
*/
public function testInNullException() {
$magicQuery = new MagicQuery();

$sql = 'SELECT * FROM users WHERE status IN :statuses!';
$this->expectException(MagicQueryException::class);
$magicQuery->build($sql, ['statuses' => NULL]);
}

/**
* @expectedException \Mouf\Database\MagicQueryException
*/
public function testInvalidSql() {
$magicQuery = new MagicQuery();

$sql = 'SELECT * FROM users WHERE date_end => :startDate';
$this->expectException(MagicQueryException::class);
$this->assertEquals('SELECT * FROM users WHERE date_end => \'2014-06-06\'', self::simplifySql($magicQuery->build($sql, ['startDate' => '2014-06-06'])));
}

Expand All @@ -252,14 +248,12 @@ public function testWithCache()
$this->assertEquals($sql, self::simplifySql($magicQuery->build($sql)));
}

/**
* @expectedException \Mouf\Database\MagicQueryParserException
*/
public function testParseError()
{
$magicQuery = new MagicQuery();

$sql = '';
$this->expectException(MagicQueryParserException::class);
$magicQuery->build($sql);
}

Expand Down Expand Up @@ -392,20 +386,15 @@ public function testMatchAgainst()
$this->assertEquals($expectedSql, self::simplifySql($magicQuery->build($sql, $params)));
}

/**
* @expectedException \Mouf\Database\MagicQueryMissingConnectionException
*/
public function testMisconfiguration()
{
$magicQuery = new MagicQuery();

$sql = "SELECT role.* FROM magicjoin(role) WHERE right.label = 'my_right'";
$this->expectException(MagicQueryMissingConnectionException::class);
$magicQuery->build($sql);
}

/**
*
*/
public function testTwig()
{
$magicQuery = new MagicQuery();
Expand Down

0 comments on commit 3b10344

Please sign in to comment.