Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,8 @@
<exclude name="SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile.MoreNamespacesInFile" />
</rule>

<!-- Deferred: long lines in test data providers -->
<rule ref="Generic.Files.LineLength.TooLong">
<exclude-pattern>tests/</exclude-pattern>
</rule>

<!-- Deferred: traversable/return type hints on test data providers -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification">
<exclude-pattern>tests/</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint">
<exclude-pattern>tests/</exclude-pattern>
</rule>

<!-- Deferred: test stubs use snake_case properties matching DB columns -->
<rule ref="Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps">
<exclude-pattern>tests/</exclude-pattern>
</rule>

<!-- Deferred: test methods use snake_case for readability -->
<rule ref="Generic.NamingConventions.CamelCapsFunctionName.ScopeNotCamelCaps">
<exclude-pattern>tests/</exclude-pattern>
</rule>
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
<exclude-pattern>tests/</exclude-pattern>
</rule>

<!-- Deferred: test stubs lack type hints and use multi-property declarations -->
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingAnyTypeHint">
<exclude-pattern>tests/</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint">
<exclude-pattern>tests/</exclude-pattern>
</rule>
<rule ref="PSR2.Classes.PropertyDeclaration.Multiple">
<exclude-pattern>tests/</exclude-pattern>
</rule>
<rule ref="Squiz.Classes.ValidClassName.NotPascalCase">
<exclude-pattern>tests/</exclude-pattern>
</rule>
</ruleset>
35 changes: 22 additions & 13 deletions tests/DbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#[CoversClass(Db::class)]
class DbTest extends TestCase
{
protected $object;
protected Db $object;

protected function setUp(): void
{
Expand Down Expand Up @@ -53,17 +53,17 @@ public function testFetchingAll(): void

public function testFetchingClass(): void
{
$line = $this->object->select('*')->from('unit')->fetch('Respect\Relational\testFetchingClass');
$this->assertInstanceOF('Respect\Relational\testFetchingClass', $line);
$line = $this->object->select('*')->from('unit')->fetch('Respect\Relational\TestFetchingClass');
$this->assertInstanceOF('Respect\Relational\TestFetchingClass', $line);
}

public function testFetchingClassArgs(): void
{
$line = $this->object->select('*')->from('unit')->fetch(
'Respect\Relational\testFetchingClassArgs',
'Respect\Relational\TestFetchingClassArgs',
['foo'],
);
$this->assertInstanceOF('Respect\Relational\testFetchingClassArgs', $line);
$this->assertInstanceOF('Respect\Relational\TestFetchingClassArgs', $line);
$this->assertEquals('foo', $line->testd);
}

Expand All @@ -81,7 +81,7 @@ static function ($row) {

public function testFetchingInto(): void
{
$x = new testFetchingInto();
$x = new TestFetchingInto();
$this->object->select('*')->from('unit')->where(['testb' => 'abc'])->fetch($x);
$this->assertEquals('abc', $x->testb);
}
Expand All @@ -94,7 +94,8 @@ public function testRawSql(): void

public function testFetchingArray(): void
{
$line = $this->object->select('*')->from('unit')->where(['testb' => 'abc'])->fetch(PDO::FETCH_ASSOC);
$line = $this->object->select('*')->from('unit')
->where(['testb' => 'abc'])->fetch(PDO::FETCH_ASSOC);
$this->assertTrue(is_array($line));
}

Expand Down Expand Up @@ -123,19 +124,27 @@ protected function tearDown(): void
}
}

class testFetchingClass
class TestFetchingClass
{
public $testa, $testb, $testez;
public int|null $testa = null;

public string|null $testb = null;

public int|null $testez = null;
}

class testFetchingInto
class TestFetchingInto
{
public $testa, $testb, $testez;
public int|null $testa = null;

public string|null $testb = null;

public int|null $testez = null;
}

class testFetchingClassArgs
class TestFetchingClassArgs
{
public function __construct(public $testd)
public function __construct(public string|null $testd = null)
{
}
}
Loading
Loading