Skip to content

Commit

Permalink
Add test to ensure custom connections can be used with find queries
Browse files Browse the repository at this point in the history
  • Loading branch information
stevebauman committed Oct 14, 2023
1 parent c5b7a83 commit 138acd5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/Feature/Emulator/EmulatedModelQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,29 @@ public function test_find()
$this->assertNull(TestModelStub::find($dn));

$user = TestModelStub::create(['cn' => 'John Doe']);

TestModelStub::create(['cn' => 'Jane Doe']);

$this->assertTrue($user->is(TestModelStub::find($dn)));
}

public function test_find_with_custom_connection()
{
Container::addConnection(new Connection([
'base_dn' => 'dc=foo,dc=com',
]), 'foo');

DirectoryEmulator::setup('foo');

$dn = 'cn=John Doe,dc=foo,dc=com';

$this->assertNull(TestModelStubWithFooConnection::find($dn));

$user = TestModelStubWithFooConnection::create(['cn' => 'John Doe']);

$this->assertTrue($user->is(TestModelStubWithFooConnection::find($dn)));
}

public function test_find_by_guid()
{
$guid = Uuid::uuid4()->toString();
Expand Down Expand Up @@ -715,6 +734,11 @@ class TestModelStub extends Entry
public static array $objectClasses = ['one', 'two'];
}

class TestModelStubWithFooConnection extends TestModelStub
{
protected ?string $connection = 'foo';
}

class TestHasManyInStub extends TestModelStub
{
public function members(): HasManyIn
Expand Down

0 comments on commit 138acd5

Please sign in to comment.