Skip to content

Commit b333386

Browse files
staabmclxmstaab
andauthored
Skip Rule* tests when not using MysqliReflector (#284)
Co-authored-by: Markus Staab <[email protected]>
1 parent e1afaa5 commit b333386

11 files changed

+55
-10
lines changed

tests/ReflectorFactory.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ final class ReflectorFactory
1313
{
1414
public static function create(string $cacheFile): QueryReflector
1515
{
16+
// handle defaults
1617
if (false !== getenv('GITHUB_ACTION')) {
1718
$host = getenv('DBA_HOST') ?: '127.0.0.1';
1819
$user = getenv('DBA_USER') ?: 'root';
@@ -27,6 +28,10 @@ public static function create(string $cacheFile): QueryReflector
2728

2829
$mode = getenv('DBA_MODE') ?: 'recording';
2930
$reflector = getenv('DBA_REFLECTOR') ?: 'mysqli';
31+
32+
// make env vars available to tests, in case non are defined yet
33+
putenv('DBA_REFLECTOR='.$reflector);
34+
3035
if ('recording' === $mode) {
3136
if ('mysqli' === $reflector) {
3237
$mysqli = @new mysqli($host, $user, $password, $dbname);

tests/rules/PdoStatementExecuteMethodRuleTest.php renamed to tests/rules/PdoStatementExecuteMethodRuleMysqliReflectorTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* @extends AbstractServiceAwareRuleTestCase<PdoStatementExecuteMethodRule>
1111
*/
12-
class PdoStatementExecuteMethodRuleTest extends AbstractServiceAwareRuleTestCase
12+
class PdoStatementExecuteMethodRuleMysqliReflectorTest extends AbstractServiceAwareRuleTestCase
1313
{
1414
protected function getRule(): Rule
1515
{
@@ -18,6 +18,10 @@ protected function getRule(): Rule
1818

1919
public function testParameterErrors(): void
2020
{
21+
if ('mysqli' !== getenv('DBA_REFLECTOR')) {
22+
$this->markTestSkipped('Only works with MysqliReflector');
23+
}
24+
2125
require_once __DIR__.'/data/pdo-stmt-execute-error.php';
2226

2327
$this->analyse([__DIR__.'/data/pdo-stmt-execute-error.php'], [

tests/rules/SyntaxErrorInPreparedStatementMethodRuleTest.php renamed to tests/rules/SyntaxErrorInPreparedStatementMethodRuleMysqliReflectorTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* @extends AbstractServiceAwareRuleTestCase<SyntaxErrorInPreparedStatementMethodRule>
1111
*/
12-
class SyntaxErrorInPreparedStatementMethodRuleTest extends AbstractServiceAwareRuleTestCase
12+
class SyntaxErrorInPreparedStatementMethodRuleMysqliReflectorTest extends AbstractServiceAwareRuleTestCase
1313
{
1414
protected function getRule(): Rule
1515
{
@@ -18,6 +18,10 @@ protected function getRule(): Rule
1818

1919
public function testSyntaxErrorInQueryRule(): void
2020
{
21+
if ('mysqli' !== getenv('DBA_REFLECTOR')) {
22+
$this->markTestSkipped('Only works with MysqliReflector');
23+
}
24+
2125
require_once __DIR__.'/data/syntax-error-in-prepared-statement.php';
2226

2327
$this->analyse([__DIR__.'/data/syntax-error-in-prepared-statement.php'], [

tests/rules/SyntaxErrorInPreparedStatementMethodSubclassedRuleTest.php renamed to tests/rules/SyntaxErrorInPreparedStatementMethodSubclassedRuleMysqliReflectorTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* @extends AbstractServiceAwareRuleTestCase<SyntaxErrorInPreparedStatementMethodRule>
1111
*/
12-
class SyntaxErrorInPreparedStatementMethodSubclassedRuleTest extends AbstractServiceAwareRuleTestCase
12+
class SyntaxErrorInPreparedStatementMethodSubclassedRuleMysqliReflectorTest extends AbstractServiceAwareRuleTestCase
1313
{
1414
protected function getRule(): Rule
1515
{
@@ -18,6 +18,10 @@ protected function getRule(): Rule
1818

1919
public function testSyntaxErrorInQueryRule(): void
2020
{
21+
if ('mysqli' !== getenv('DBA_REFLECTOR')) {
22+
$this->markTestSkipped('Only works with MysqliReflector');
23+
}
24+
2125
require_once __DIR__.'/data/syntax-error-in-method-subclassed.php';
2226

2327
$this->analyse([__DIR__.'/data/syntax-error-in-method-subclassed.php'], [

tests/rules/SyntaxErrorInQueryFunctionRuleTest.php renamed to tests/rules/SyntaxErrorInQueryFunctionRuleMysqliReflectorTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* @extends AbstractServiceAwareRuleTestCase<SyntaxErrorInQueryFunctionRule>
1111
*/
12-
class SyntaxErrorInQueryFunctionRuleTest extends AbstractServiceAwareRuleTestCase
12+
class SyntaxErrorInQueryFunctionRuleMysqliReflectorTest extends AbstractServiceAwareRuleTestCase
1313
{
1414
protected function getRule(): Rule
1515
{
@@ -18,6 +18,10 @@ protected function getRule(): Rule
1818

1919
public function testSyntaxErrorInQueryRule(): void
2020
{
21+
if ('mysqli' !== getenv('DBA_REFLECTOR')) {
22+
$this->markTestSkipped('Only works with MysqliReflector');
23+
}
24+
2125
require_once __DIR__.'/data/syntax-error-in-query-function.php';
2226

2327
$this->analyse([__DIR__.'/data/syntax-error-in-query-function.php'], [

tests/rules/SyntaxErrorInQueryMethodRuleTest.php renamed to tests/rules/SyntaxErrorInQueryMethodRuleMysqliReflectorTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* @extends AbstractServiceAwareRuleTestCase<SyntaxErrorInQueryMethodRule>
1111
*/
12-
class SyntaxErrorInQueryMethodRuleTest extends AbstractServiceAwareRuleTestCase
12+
class SyntaxErrorInQueryMethodRuleMysqliReflectorTest extends AbstractServiceAwareRuleTestCase
1313
{
1414
protected function getRule(): Rule
1515
{
@@ -18,6 +18,10 @@ protected function getRule(): Rule
1818

1919
public function testSyntaxErrorInQueryRule(): void
2020
{
21+
if ('mysqli' !== getenv('DBA_REFLECTOR')) {
22+
$this->markTestSkipped('Only works with MysqliReflector');
23+
}
24+
2125
require_once __DIR__.'/data/syntax-error-in-query-method.php';
2226

2327
$this->analyse([__DIR__.'/data/syntax-error-in-query-method.php'], [

tests/rules/SyntaxErrorInQueryMethodSubclassedRuleTest.php renamed to tests/rules/SyntaxErrorInQueryMethodSubclassedRuleMysqliReflectorTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* @extends AbstractServiceAwareRuleTestCase<SyntaxErrorInQueryMethodRule>
1111
*/
12-
class SyntaxErrorInQueryMethodSubclassedRuleTest extends AbstractServiceAwareRuleTestCase
12+
class SyntaxErrorInQueryMethodSubclassedRuleMysqliReflectorTest extends AbstractServiceAwareRuleTestCase
1313
{
1414
protected function getRule(): Rule
1515
{
@@ -18,6 +18,10 @@ protected function getRule(): Rule
1818

1919
public function testSyntaxErrorInQueryRule(): void
2020
{
21+
if ('mysqli' !== getenv('DBA_REFLECTOR')) {
22+
$this->markTestSkipped('Only works with MysqliReflector');
23+
}
24+
2125
require_once __DIR__.'/data/syntax-error-in-method-subclassed.php';
2226

2327
$this->analyse([__DIR__.'/data/syntax-error-in-method-subclassed.php'], [

tests/rules/UnresolvablePdoStatementRuleTest.php renamed to tests/rules/UnresolvablePdoStatementRuleMysqliReflectorTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* @extends AbstractServiceAwareRuleTestCase<PdoStatementExecuteMethodRule>
1313
*/
14-
class UnresolvablePdoStatementRuleTest extends AbstractServiceAwareRuleTestCase
14+
class UnresolvablePdoStatementRuleMysqliReflectorTest extends AbstractServiceAwareRuleTestCase
1515
{
1616
protected function setUp(): void
1717
{
@@ -30,6 +30,10 @@ protected function getRule(): Rule
3030

3131
public function testSyntaxErrorInQueryRule(): void
3232
{
33+
if ('mysqli' !== getenv('DBA_REFLECTOR')) {
34+
$this->markTestSkipped('Only works with MysqliReflector');
35+
}
36+
3337
require_once __DIR__.'/data/unresolvable-pdo-statement.php';
3438

3539
$this->analyse([__DIR__.'/data/unresolvable-pdo-statement.php'], [

tests/rules/UnresolvablePreparedStatementRuleTest.php renamed to tests/rules/UnresolvablePreparedStatementRuleMysqliReflectorTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* @extends AbstractServiceAwareRuleTestCase<SyntaxErrorInPreparedStatementMethodRule>
1313
*/
14-
class UnresolvablePreparedStatementRuleTest extends AbstractServiceAwareRuleTestCase
14+
class UnresolvablePreparedStatementRuleMysqliReflectorTest extends AbstractServiceAwareRuleTestCase
1515
{
1616
protected function setUp(): void
1717
{
@@ -30,6 +30,10 @@ protected function getRule(): Rule
3030

3131
public function testSyntaxErrorInQueryRule(): void
3232
{
33+
if ('mysqli' !== getenv('DBA_REFLECTOR')) {
34+
$this->markTestSkipped('Only works with MysqliReflector');
35+
}
36+
3337
require_once __DIR__.'/data/unresolvable-statement.php';
3438

3539
$this->analyse([__DIR__.'/data/unresolvable-statement.php'], [

tests/rules/UnresolvableQueryFunctionRuleTest.php renamed to tests/rules/UnresolvableQueryFunctionRuleMysqliReflectorTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* @extends AbstractServiceAwareRuleTestCase<SyntaxErrorInQueryFunctionRule>
1313
*/
14-
class UnresolvableQueryFunctionRuleTest extends AbstractServiceAwareRuleTestCase
14+
class UnresolvableQueryFunctionRuleMysqliReflectorTest extends AbstractServiceAwareRuleTestCase
1515
{
1616
protected function setUp(): void
1717
{
@@ -30,6 +30,10 @@ protected function getRule(): Rule
3030

3131
public function testSyntaxErrorInQueryRule(): void
3232
{
33+
if ('mysqli' !== getenv('DBA_REFLECTOR')) {
34+
$this->markTestSkipped('Only works with MysqliReflector');
35+
}
36+
3337
require_once __DIR__.'/data/unresolvable-query-in-function.php';
3438

3539
$this->analyse([__DIR__.'/data/unresolvable-query-in-function.php'], [

0 commit comments

Comments
 (0)