Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
stevebauman committed Nov 7, 2023
1 parent 1daaad9 commit 3e391ff
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions tests/Unit/Models/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use LdapRecord\Models\BatchModification;
use LdapRecord\Models\Entry;
use LdapRecord\Models\Model;
use LdapRecord\Testing\DirectoryFake;
use LdapRecord\Testing\LdapFake;
use LdapRecord\Tests\TestCase;

class ModelTest extends TestCase
Expand Down Expand Up @@ -729,19 +731,32 @@ public function test_generated_dns_are_properly_escaped()
$this->assertEquals('cn=John\5c\2c\3d\2b\3c\3e\3b\5c\23Doe,dc=local,dc=com', $model->getCreatableDn());
}

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

DirectoryFake::setup()->getLdapConnection()->expect(
LdapFake::operation('add')
->once()
->with(
'cn=foo,dc=local,dc=com',
['cn' => ['foo'], 'objectclass' => ['bar']]
)
->andReturnTrue()
);

$model = new Entry();

$model->inside('{base}');

$model->cn = 'foo';
$model->objectclass = ['bar'];

$model->save();

$this->assertEquals('cn=foo,dc=local,dc=com', $model->getCreatableDn());
$this->assertEquals('cn=foo,dc=local,dc=com', $model->getDn());
}

public function test_setting_dn_attributes_set_distinguished_name_on_model()
Expand Down

0 comments on commit 3e391ff

Please sign in to comment.