Pass integer IDs as-is
This commit is contained in:
parent
2d8f8b6e87
commit
a10ecbb1cd
|
@ -15,7 +15,7 @@ class Parameters
|
|||
*/
|
||||
public static function id(mixed $key): array
|
||||
{
|
||||
return [':id' => is_string($key) ? $key : "$key"];
|
||||
return [':id' => is_int($key) || is_string($key) ? $key : "$key"];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Test\Integration\SQLite;
|
||||
|
||||
use BitBadger\PDODocument\{Custom, Field, Find};
|
||||
use BitBadger\PDODocument\{Custom, Document, Field, Find};
|
||||
use PHPUnit\Framework\Attributes\TestDox;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Test\Integration\TestDocument;
|
||||
|
@ -53,6 +53,15 @@ class FindTest extends TestCase
|
|||
$this->assertEquals('two', $doc->id, 'An incorrect document was returned');
|
||||
}
|
||||
|
||||
#[TestDox('By ID succeeds when a document is found with numeric ID')]
|
||||
public function testByIdSucceedsWhenADocumentIsFoundWithNumericId(): void
|
||||
{
|
||||
Document::insert(ThrowawayDb::TABLE, ['id' => 18, 'value' => 'howdy']);
|
||||
$doc = Find::byId(ThrowawayDb::TABLE, 18, TestDocument::class);
|
||||
$this->assertNotFalse($doc, 'There should have been a document returned');
|
||||
$this->assertEquals('18', $doc->id, 'An incorrect document was returned');
|
||||
}
|
||||
|
||||
#[TestDox('By ID succeeds when a document is not found')]
|
||||
public function testByIdSucceedsWhenADocumentIsNotFound(): void
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user