Update to PHP 8.4, new option lib

This commit is contained in:
2024-09-30 23:39:23 -04:00
parent df436c9ef4
commit 4b29345dc7
16 changed files with 151 additions and 151 deletions

View File

@@ -85,8 +85,8 @@ class FindTest extends TestCase
public function testByIdSucceedsWhenADocumentIsFound(): void
{
$doc = Find::byId(ThrowawayDb::TABLE, 'two', TestDocument::class);
$this->assertTrue($doc->isSome(), 'There should have been a document returned');
$this->assertEquals('two', $doc->get()->id, 'An incorrect document was returned');
$this->assertTrue($doc->isSome, 'There should have been a document returned');
$this->assertEquals('two', $doc->value->id, 'An incorrect document was returned');
}
#[TestDox('byId() succeeds when a document is found with numeric ID')]
@@ -95,15 +95,15 @@ class FindTest extends TestCase
Delete::byFields(ThrowawayDb::TABLE, [Field::notExists('absent')]);
Document::insert(ThrowawayDb::TABLE, ['id' => 18, 'value' => 'howdy']);
$doc = Find::byId(ThrowawayDb::TABLE, 18, NumDocument::class);
$this->assertTrue($doc->isSome(), 'There should have been a document returned');
$this->assertEquals(18, $doc->get()->id, 'An incorrect document was returned');
$this->assertTrue($doc->isSome, 'There should have been a document returned');
$this->assertEquals(18, $doc->value->id, 'An incorrect document was returned');
}
#[TestDox('byId() succeeds when a document is not found')]
public function testByIdSucceedsWhenADocumentIsNotFound(): void
{
$doc = Find::byId(ThrowawayDb::TABLE, 'seventy-five', TestDocument::class);
$this->assertTrue($doc->isNone(), 'There should not have been a document returned');
$this->assertTrue($doc->isNone, 'There should not have been a document returned');
}
#[TestDox('byFields() succeeds when documents are found')]
@@ -229,16 +229,16 @@ class FindTest extends TestCase
public function testFirstByFieldsSucceedsWhenADocumentIsFound(): void
{
$doc = Find::firstByFields(ThrowawayDb::TABLE, [Field::equal('value', 'another')], TestDocument::class);
$this->assertTrue($doc->isSome(), 'There should have been a document returned');
$this->assertEquals('two', $doc->get()->id, 'The incorrect document was returned');
$this->assertTrue($doc->isSome, 'There should have been a document returned');
$this->assertEquals('two', $doc->value->id, 'The incorrect document was returned');
}
#[TestDox('firstByFields() succeeds when multiple documents are found')]
public function testFirstByFieldsSucceedsWhenMultipleDocumentsAreFound(): void
{
$doc = Find::firstByFields(ThrowawayDb::TABLE, [Field::equal('sub.foo', 'green')], TestDocument::class);
$this->assertTrue($doc->isSome(), 'There should have been a document returned');
$this->assertContains($doc->get()->id, ['two', 'four'], 'An incorrect document was returned');
$this->assertTrue($doc->isSome, 'There should have been a document returned');
$this->assertContains($doc->value->id, ['two', 'four'], 'An incorrect document was returned');
}
#[TestDox('firstByFields() succeeds when multiple ordered documents are found')]
@@ -246,31 +246,31 @@ class FindTest extends TestCase
{
$doc = Find::firstByFields(ThrowawayDb::TABLE, [Field::equal('sub.foo', 'green')], TestDocument::class,
orderBy: [Field::named('n:num_value DESC')]);
$this->assertTrue($doc->isSome(), 'There should have been a document returned');
$this->assertEquals('four', $doc->get()->id, 'The incorrect document was returned');
$this->assertTrue($doc->isSome, 'There should have been a document returned');
$this->assertEquals('four', $doc->value->id, 'The incorrect document was returned');
}
#[TestDox('firstByFields() succeeds when a document is not found')]
public function testFirstByFieldsSucceedsWhenADocumentIsNotFound(): void
{
$doc = Find::firstByFields(ThrowawayDb::TABLE, [Field::equal('value', 'absent')], TestDocument::class);
$this->assertTrue($doc->isNone(), 'There should not have been a document returned');
$this->assertTrue($doc->isNone, 'There should not have been a document returned');
}
#[TestDox('firstByContains() succeeds when a document is found')]
public function testFirstByContainsSucceedsWhenADocumentIsFound(): void
{
$doc = Find::firstByContains(ThrowawayDb::TABLE, ['value' => 'FIRST!'], TestDocument::class);
$this->assertTrue($doc->isSome(), 'There should have been a document returned');
$this->assertEquals('one', $doc->get()->id, 'The incorrect document was returned');
$this->assertTrue($doc->isSome, 'There should have been a document returned');
$this->assertEquals('one', $doc->value->id, 'The incorrect document was returned');
}
#[TestDox('firstByContains() succeeds when multiple documents are found')]
public function testFirstByContainsSucceedsWhenMultipleDocumentsAreFound(): void
{
$doc = Find::firstByContains(ThrowawayDb::TABLE, ['value' => 'purple'], TestDocument::class);
$this->assertTrue($doc->isSome(), 'There should have been a document returned');
$this->assertContains($doc->get()->id, ['four', 'five'], 'An incorrect document was returned');
$this->assertTrue($doc->isSome, 'There should have been a document returned');
$this->assertContains($doc->value->id, ['four', 'five'], 'An incorrect document was returned');
}
#[TestDox('firstByContains() succeeds when multiple ordered documents are found')]
@@ -278,31 +278,31 @@ class FindTest extends TestCase
{
$doc = Find::firstByContains(ThrowawayDb::TABLE, ['value' => 'purple'], TestDocument::class,
[Field::named('sub.bar NULLS FIRST')]);
$this->assertTrue($doc->isSome(), 'There should have been a document returned');
$this->assertEquals('five', $doc->get()->id, 'The incorrect document was returned');
$this->assertTrue($doc->isSome, 'There should have been a document returned');
$this->assertEquals('five', $doc->value->id, 'The incorrect document was returned');
}
#[TestDox('firstByContains() succeeds when a document is not found')]
public function testFirstByContainsSucceedsWhenADocumentIsNotFound(): void
{
$doc = Find::firstByContains(ThrowawayDb::TABLE, ['value' => 'indigo'], TestDocument::class);
$this->assertTrue($doc->isNone(), 'There should not have been a document returned');
$this->assertTrue($doc->isNone, 'There should not have been a document returned');
}
#[TestDox('firstByJsonPath() succeeds when a document is found')]
public function testFirstByJsonPathSucceedsWhenADocumentIsFound(): void
{
$doc = Find::firstByJsonPath(ThrowawayDb::TABLE, '$.num_value ? (@ == 10)', TestDocument::class);
$this->assertTrue($doc->isSome(), 'There should have been a document returned');
$this->assertEquals('two', $doc->get()->id, 'The incorrect document was returned');
$this->assertTrue($doc->isSome, 'There should have been a document returned');
$this->assertEquals('two', $doc->value->id, 'The incorrect document was returned');
}
#[TestDox('firstByJsonPath() succeeds when multiple documents are found')]
public function testFirstByJsonPathSucceedsWhenMultipleDocumentsAreFound(): void
{
$doc = Find::firstByJsonPath(ThrowawayDb::TABLE, '$.num_value ? (@ > 10)', TestDocument::class);
$this->assertTrue($doc->isSome(), 'There should have been a document returned');
$this->assertContains($doc->get()->id, ['four', 'five'], 'An incorrect document was returned');
$this->assertTrue($doc->isSome, 'There should have been a document returned');
$this->assertContains($doc->value->id, ['four', 'five'], 'An incorrect document was returned');
}
#[TestDox('firstByJsonPath() succeeds when multiple ordered documents are found')]
@@ -310,14 +310,14 @@ class FindTest extends TestCase
{
$doc = Find::firstByJsonPath(ThrowawayDb::TABLE, '$.num_value ? (@ > 10)', TestDocument::class,
[Field::named('id DESC')]);
$this->assertTrue($doc->isSome(), 'There should have been a document returned');
$this->assertEquals('four', $doc->get()->id, 'The incorrect document was returned');
$this->assertTrue($doc->isSome, 'There should have been a document returned');
$this->assertEquals('four', $doc->value->id, 'The incorrect document was returned');
}
#[TestDox('firstByJsonPath() succeeds when a document is not found')]
public function testFirstByJsonPathSucceedsWhenADocumentIsNotFound(): void
{
$doc = Find::firstByJsonPath(ThrowawayDb::TABLE, '$.num_value ? (@ > 100)', TestDocument::class);
$this->assertTrue($doc->isNone(), 'There should not have been a document returned');
$this->assertTrue($doc->isNone, 'There should not have been a document returned');
}
}