diff --git a/src/ConnectionManager.php b/src/ConnectionManager.php index 339dea4d..8bef8d15 100644 --- a/src/ConnectionManager.php +++ b/src/ConnectionManager.php @@ -43,7 +43,7 @@ class ConnectionManager /** * Constructor. */ - public function __construct($dispatcher = new Dispatcher()) + public function __construct($dispatcher = new Dispatcher) { $this->dispatcher = $dispatcher; } diff --git a/src/Container.php b/src/Container.php index 0979842f..5a3bd7f4 100644 --- a/src/Container.php +++ b/src/Container.php @@ -50,7 +50,7 @@ public static function __callStatic(string $method, array $parameters): mixed /** * Constructor. */ - public function __construct(ConnectionManager $manager = new ConnectionManager()) + public function __construct(ConnectionManager $manager = new ConnectionManager) { $this->manager = $manager; } diff --git a/src/DetailedError.php b/src/DetailedError.php index c17a2ef0..e9d9609d 100644 --- a/src/DetailedError.php +++ b/src/DetailedError.php @@ -11,8 +11,7 @@ public function __construct( protected int $errorCode, protected string $errorMessage, protected ?string $diagnosticMessage - ) { - } + ) {} /** * Get the LDAP error code. diff --git a/src/Events/Dispatcher.php b/src/Events/Dispatcher.php index f89a4988..304e15cc 100644 --- a/src/Events/Dispatcher.php +++ b/src/Events/Dispatcher.php @@ -225,7 +225,7 @@ protected function createClassCallable(string $listener): callable { [$class, $method] = $this->parseListenerCallback($listener); - return [new $class(), $method]; + return [new $class, $method]; } /** diff --git a/src/Events/NullDispatcher.php b/src/Events/NullDispatcher.php index 4c29df4c..31f95cb7 100644 --- a/src/Events/NullDispatcher.php +++ b/src/Events/NullDispatcher.php @@ -44,9 +44,7 @@ public function until(string|object $event, mixed $payload = []): ?array /** * Fire an event and call the listeners. */ - public function fire(string|object $event, mixed $payload = [], bool $halt = false): void - { - } + public function fire(string|object $event, mixed $payload = [], bool $halt = false): void {} /** * Fire an event and call the listeners. diff --git a/src/LdapResultResponse.php b/src/LdapResultResponse.php index 4f18b3d1..c0c1e830 100644 --- a/src/LdapResultResponse.php +++ b/src/LdapResultResponse.php @@ -13,8 +13,7 @@ public function __construct( public readonly ?string $errorMessage = null, public readonly ?array $referrals = null, public readonly ?array $controls = null, - ) { - } + ) {} /** * Determine if the LDAP response indicates a successful status. diff --git a/src/Models/ActiveDirectory/ExchangeDatabase.php b/src/Models/ActiveDirectory/ExchangeDatabase.php index 8e096fc1..e32f8200 100644 --- a/src/Models/ActiveDirectory/ExchangeDatabase.php +++ b/src/Models/ActiveDirectory/ExchangeDatabase.php @@ -16,6 +16,6 @@ public static function boot(): void { parent::boot(); - static::addGlobalScope(new Scopes\InConfigurationContext()); + static::addGlobalScope(new Scopes\InConfigurationContext); } } diff --git a/src/Models/ActiveDirectory/ExchangeServer.php b/src/Models/ActiveDirectory/ExchangeServer.php index d974c161..5e13d405 100644 --- a/src/Models/ActiveDirectory/ExchangeServer.php +++ b/src/Models/ActiveDirectory/ExchangeServer.php @@ -16,7 +16,7 @@ public static function boot(): void { parent::boot(); - static::addGlobalScope(new Scopes\HasServerRoleAttribute()); - static::addGlobalScope(new Scopes\InConfigurationContext()); + static::addGlobalScope(new Scopes\HasServerRoleAttribute); + static::addGlobalScope(new Scopes\InConfigurationContext); } } diff --git a/src/Models/Attributes/TSPropertyArray.php b/src/Models/Attributes/TSPropertyArray.php index 360fee00..a8101814 100644 --- a/src/Models/Attributes/TSPropertyArray.php +++ b/src/Models/Attributes/TSPropertyArray.php @@ -77,7 +77,7 @@ public function __construct(mixed $tsPropertyArray = null) $tsPropertyArray = $tsPropertyArray ?: self::DEFAULTS; foreach ($tsPropertyArray as $key => $value) { - $tsProperty = new TSProperty(); + $tsProperty = new TSProperty; $this->tsProperty[$key] = $tsProperty->setName($key)->setValue($value); } diff --git a/src/Models/Attributes/Timestamp.php b/src/Models/Attributes/Timestamp.php index 40a9149d..4d35c7e4 100644 --- a/src/Models/Attributes/Timestamp.php +++ b/src/Models/Attributes/Timestamp.php @@ -184,7 +184,7 @@ protected function convertWindowsIntegerTimeToDateTime(string|int|null $value = return (int) $value; } - return (new DateTime())->setTimestamp( + return (new DateTime)->setTimestamp( round($value / 10000000) - 11644473600 ); } diff --git a/src/Models/Concerns/CanAuthenticate.php b/src/Models/Concerns/CanAuthenticate.php index 96a0df8b..93914eca 100644 --- a/src/Models/Concerns/CanAuthenticate.php +++ b/src/Models/Concerns/CanAuthenticate.php @@ -40,9 +40,7 @@ public function getRememberToken(): string /** * Set the token value for the "remember me" session. */ - public function setRememberToken($value): void - { - } + public function setRememberToken($value): void {} /** * Get the column name for the "remember me" token. diff --git a/src/Models/FreeIPA/Entry.php b/src/Models/FreeIPA/Entry.php index 433ae67b..4f29ef03 100644 --- a/src/Models/FreeIPA/Entry.php +++ b/src/Models/FreeIPA/Entry.php @@ -34,7 +34,7 @@ protected static function boot(): void // Here we'll add a global scope to all FreeIPA models to ensure the // Entry UUID is always selected on each query. This attribute is // virtual, so it must be manually selected to be included. - static::addGlobalScope(new AddEntryUuidToSelects()); + static::addGlobalScope(new AddEntryUuidToSelects); } /** diff --git a/src/Models/Model.php b/src/Models/Model.php index 0b41b97c..1cfad585 100644 --- a/src/Models/Model.php +++ b/src/Models/Model.php @@ -228,7 +228,7 @@ public static function make(array $attributes = []): static */ public static function on(?string $connection = null): Builder { - $instance = new static(); + $instance = new static; $instance->setConnection($connection); @@ -253,7 +253,7 @@ public static function getRootDse(?string $connection = null): Model /** @var Model $model */ $model = static::getRootDseModel(); - return $model::on($connection ?? (new $model())->getConnectionName()) + return $model::on($connection ?? (new $model)->getConnectionName()) ->in() ->read() ->whereHas('objectclass') @@ -267,7 +267,7 @@ public static function getRootDse(?string $connection = null): Model */ protected static function getRootDseModel(): string { - $instance = new static(); + $instance = new static; return match (true) { $instance instanceof Types\ActiveDirectory => ActiveDirectory\Entry::class, @@ -1082,7 +1082,7 @@ public static function destroy(mixed $dns, bool $recursive = false): int { $count = 0; - $instance = new static(); + $instance = new static; if ($dns instanceof Collection) { $dns = $dns->modelDns()->toArray(); diff --git a/src/Models/ModelDoesNotExistException.php b/src/Models/ModelDoesNotExistException.php index b90d0f5c..98efa986 100644 --- a/src/Models/ModelDoesNotExistException.php +++ b/src/Models/ModelDoesNotExistException.php @@ -16,7 +16,7 @@ class ModelDoesNotExistException extends LdapRecordException */ public static function forModel(Model $model): static { - return (new static())->setModel($model); + return (new static)->setModel($model); } /** diff --git a/src/Models/OpenLDAP/Entry.php b/src/Models/OpenLDAP/Entry.php index 2bc6d25e..e20016a4 100644 --- a/src/Models/OpenLDAP/Entry.php +++ b/src/Models/OpenLDAP/Entry.php @@ -26,7 +26,7 @@ protected static function boot(): void // Here we'll add a global scope to all OpenLDAP models to ensure the // Entry UUID is always selected on each query. This attribute is // virtual, so it must be manually selected to be included. - static::addGlobalScope(new AddEntryUuidToSelects()); + static::addGlobalScope(new AddEntryUuidToSelects); } /** diff --git a/src/Models/Relations/Relation.php b/src/Models/Relations/Relation.php index ea0fa65e..b2d26100 100644 --- a/src/Models/Relations/Relation.php +++ b/src/Models/Relations/Relation.php @@ -234,7 +234,7 @@ public function getDefaultModel(): string */ public function getNewDefaultModel(): Model { - $model = new $this->default(); + $model = new $this->default; $model->setConnection($this->parent->getConnectionName()); diff --git a/src/Query/Builder.php b/src/Query/Builder.php index 8c7ec7a8..2f3c4198 100644 --- a/src/Query/Builder.php +++ b/src/Query/Builder.php @@ -135,7 +135,7 @@ class Builder public function __construct(Connection $connection) { $this->connection = $connection; - $this->grammar = new Grammar(); + $this->grammar = new Grammar; } /** @@ -686,11 +686,11 @@ public function sole(array|string $columns = ['*']): Model|array $result = $this->limit(2)->get($columns); if (empty($result)) { - throw new ObjectsNotFoundException(); + throw new ObjectsNotFoundException; } if (count($result) > 1) { - throw new MultipleObjectsFoundException(); + throw new MultipleObjectsFoundException; } return reset($result); diff --git a/src/Query/Events/QueryExecuted.php b/src/Query/Events/QueryExecuted.php index 841a596f..95cadd6a 100644 --- a/src/Query/Events/QueryExecuted.php +++ b/src/Query/Events/QueryExecuted.php @@ -13,8 +13,6 @@ class QueryExecuted /** * The number of milliseconds it took to execute the query. - * - * @var ?float */ protected ?float $time; diff --git a/src/Query/Filter/ParserException.php b/src/Query/Filter/ParserException.php index 68a4ca17..3c3d68e4 100644 --- a/src/Query/Filter/ParserException.php +++ b/src/Query/Filter/ParserException.php @@ -4,6 +4,4 @@ use LdapRecord\LdapRecordException; -class ParserException extends LdapRecordException -{ -} +class ParserException extends LdapRecordException {} diff --git a/src/Query/Model/ActiveDirectoryBuilder.php b/src/Query/Model/ActiveDirectoryBuilder.php index ce3068ec..b360b02d 100644 --- a/src/Query/Model/ActiveDirectoryBuilder.php +++ b/src/Query/Model/ActiveDirectoryBuilder.php @@ -50,7 +50,7 @@ public function whereEnabled(): static public function whereDisabled(): static { return $this->rawFilter( - (new AccountControl())->setAccountIsDisabled()->filter() + (new AccountControl)->setAccountIsDisabled()->filter() ); } diff --git a/src/Query/MultipleObjectsFoundException.php b/src/Query/MultipleObjectsFoundException.php index 0ece752c..79ed1e3e 100644 --- a/src/Query/MultipleObjectsFoundException.php +++ b/src/Query/MultipleObjectsFoundException.php @@ -4,6 +4,4 @@ use LdapRecord\LdapRecordException; -class MultipleObjectsFoundException extends LdapRecordException -{ -} +class MultipleObjectsFoundException extends LdapRecordException {} diff --git a/src/Query/ObjectsNotFoundException.php b/src/Query/ObjectsNotFoundException.php index a9846005..85edb7f0 100644 --- a/src/Query/ObjectsNotFoundException.php +++ b/src/Query/ObjectsNotFoundException.php @@ -4,6 +4,4 @@ use LdapRecord\LdapRecordException; -class ObjectsNotFoundException extends LdapRecordException -{ -} +class ObjectsNotFoundException extends LdapRecordException {} diff --git a/src/Testing/AuthGuardFake.php b/src/Testing/AuthGuardFake.php index eb64092e..36574c0d 100644 --- a/src/Testing/AuthGuardFake.php +++ b/src/Testing/AuthGuardFake.php @@ -9,7 +9,5 @@ class AuthGuardFake extends Guard /** * Always allow binding as configured user. */ - public function bindAsConfiguredUser(): void - { - } + public function bindAsConfiguredUser(): void {} } diff --git a/src/Testing/LdapExpectationException.php b/src/Testing/LdapExpectationException.php index e2e79722..74a3ebe3 100644 --- a/src/Testing/LdapExpectationException.php +++ b/src/Testing/LdapExpectationException.php @@ -4,6 +4,4 @@ use Exception; -class LdapExpectationException extends Exception -{ -} +class LdapExpectationException extends Exception {} diff --git a/src/Testing/LdapFake.php b/src/Testing/LdapFake.php index 046221b5..7279c597 100644 --- a/src/Testing/LdapFake.php +++ b/src/Testing/LdapFake.php @@ -413,7 +413,7 @@ public function parseResult(mixed $result, int &$errorCode = 0, ?string &$dn = n { return $this->hasExpectations(__FUNCTION__) ? $this->resolveExpectation(__FUNCTION__, func_get_args()) - : new LdapResultResponse(); + : new LdapResultResponse; } /** diff --git a/tests/Integration/Concerns/MakePosixUsers.php b/tests/Integration/Concerns/MakePosixUsers.php index d8c73a05..9d9831f3 100644 --- a/tests/Integration/Concerns/MakePosixUsers.php +++ b/tests/Integration/Concerns/MakePosixUsers.php @@ -10,7 +10,7 @@ trait MakePosixUsers { protected function makePosixUser(Model $ou, array $attributes = []): PosixAccount { - return (new PosixAccount()) + return (new PosixAccount) ->inside($ou) ->fill(array_merge([ 'uid' => $this->faker()->userName(), diff --git a/tests/Integration/Concerns/MakesGroups.php b/tests/Integration/Concerns/MakesGroups.php index be3e2508..6ea58382 100644 --- a/tests/Integration/Concerns/MakesGroups.php +++ b/tests/Integration/Concerns/MakesGroups.php @@ -10,7 +10,7 @@ trait MakesGroups { protected function makeGroup(Model $ou, array $attributes = []): Group { - return (new Group()) + return (new Group) ->inside($ou) ->fill(array_merge( ['cn' => $this->faker()->name()], diff --git a/tests/Integration/Concerns/MakesPosixGroups.php b/tests/Integration/Concerns/MakesPosixGroups.php index a8512c0d..bf9cfbe3 100644 --- a/tests/Integration/Concerns/MakesPosixGroups.php +++ b/tests/Integration/Concerns/MakesPosixGroups.php @@ -10,7 +10,7 @@ trait MakesPosixGroups { protected function makePosixGroup(Model $ou, array $attributes = []): PosixGroup { - return (new PosixGroup()) + return (new PosixGroup) ->inside($ou) ->fill(array_merge([ 'cn' => $this->faker()->name(), diff --git a/tests/Integration/Concerns/MakesUsers.php b/tests/Integration/Concerns/MakesUsers.php index b63edab2..3b0309ac 100644 --- a/tests/Integration/Concerns/MakesUsers.php +++ b/tests/Integration/Concerns/MakesUsers.php @@ -9,7 +9,7 @@ trait MakesUsers { protected function makeUser(Model $ou, array $attributes = []): User { - return (new User()) + return (new User) ->inside($ou) ->fill(array_merge([ 'uid' => $this->faker()->userName(), diff --git a/tests/Unit/Auth/GuardTest.php b/tests/Unit/Auth/GuardTest.php index dc31a3d4..761ac5e4 100644 --- a/tests/Unit/Auth/GuardTest.php +++ b/tests/Unit/Auth/GuardTest.php @@ -23,7 +23,7 @@ class GuardTest extends TestCase { public function test_attempt_throws_exception_with_an_empty_username() { - $guard = new Guard(new Ldap(), new DomainConfiguration()); + $guard = new Guard(new Ldap, new DomainConfiguration); $this->expectException(UsernameRequiredException::class); @@ -32,7 +32,7 @@ public function test_attempt_throws_exception_with_an_empty_username() public function test_attempt_throws_exception_with_an_empty_password() { - $guard = new Guard(new Ldap(), new DomainConfiguration()); + $guard = new Guard(new Ldap, new DomainConfiguration); $this->expectException(PasswordRequiredException::class); @@ -59,7 +59,7 @@ public function test_bind_does_not_rebind_with_configured_user() LdapFake::operation('bind')->once()->with('user', 'pass')->andReturnResponse() ); - $guard = new Guard($ldap, new DomainConfiguration()); + $guard = new Guard($ldap, new DomainConfiguration); $guard->bind('user', 'pass'); } @@ -70,7 +70,7 @@ public function test_bind_allows_null_username_and_password() LdapFake::operation('bind')->once()->with(null, null)->andReturnResponse() ); - $guard = new Guard($ldap, new DomainConfiguration()); + $guard = new Guard($ldap, new DomainConfiguration); $guard->bind(); } @@ -81,7 +81,7 @@ public function test_bind_always_throws_exception_on_invalid_credentials() LdapFake::operation('bind')->once()->with('user', 'pass')->andReturnErrorResponse() ); - $guard = new Guard($ldap, new DomainConfiguration()); + $guard = new Guard($ldap, new DomainConfiguration); $this->expectException(BindException::class); @@ -104,7 +104,7 @@ public function test_bind_as_administrator() public function test_binding_events_are_fired_during_bind() { - $events = new Dispatcher(); + $events = new Dispatcher; $events->listen(Bound::class, function (Bound $event) use (&$firedBound) { $this->assertEquals('johndoe', $event->getUsername()); @@ -117,7 +117,7 @@ public function test_binding_events_are_fired_during_bind() LdapFake::operation('bind')->once()->with('johndoe', 'secret')->andReturnResponse() ); - $guard = new Guard($ldap, new DomainConfiguration()); + $guard = new Guard($ldap, new DomainConfiguration); $guard->setDispatcher($events); @@ -138,7 +138,7 @@ public function test_bind_failed_event_includes_exception_thrown() LdapFake::operation('bind')->once()->with('johndoe', 'secret')->andThrow(new Exception('foo')) ); - $guard = new Guard($ldap, new DomainConfiguration()); + $guard = new Guard($ldap, new DomainConfiguration); $guard->setDispatcher($events); @@ -147,7 +147,7 @@ public function test_bind_failed_event_includes_exception_thrown() public function test_auth_events_are_fired_during_attempt() { - $events = new Dispatcher(); + $events = new Dispatcher; $firedBinding = false; $firedBound = false; @@ -186,7 +186,7 @@ public function test_auth_events_are_fired_during_attempt() LdapFake::operation('bind')->once()->with('johndoe', 'secret')->andReturnResponse() ); - $guard = new Guard($ldap, new DomainConfiguration()); + $guard = new Guard($ldap, new DomainConfiguration); $guard->setDispatcher($events); @@ -200,7 +200,7 @@ public function test_auth_events_are_fired_during_attempt() public function test_all_auth_events_can_be_listened_to_with_wildcard() { - $events = new Dispatcher(); + $events = new Dispatcher; $totalFired = 0; @@ -212,7 +212,7 @@ public function test_all_auth_events_can_be_listened_to_with_wildcard() LdapFake::operation('bind')->once()->with('johndoe', 'secret')->andReturnResponse() ); - $guard = new Guard($ldap, new DomainConfiguration()); + $guard = new Guard($ldap, new DomainConfiguration); $guard->setDispatcher($events); diff --git a/tests/Unit/Configuration/DomainConfigurationTest.php b/tests/Unit/Configuration/DomainConfigurationTest.php index e7d55e5b..5aa703ee 100644 --- a/tests/Unit/Configuration/DomainConfigurationTest.php +++ b/tests/Unit/Configuration/DomainConfigurationTest.php @@ -17,14 +17,14 @@ protected function setUp(): void public function test_getting_options() { - $config = new DomainConfiguration(); + $config = new DomainConfiguration; $this->assertEmpty($config->get('username')); } public function test_setting_options() { - $config = new DomainConfiguration(); + $config = new DomainConfiguration; $config->set('username', 'foo'); @@ -33,7 +33,7 @@ public function test_setting_options() public function test_default_options() { - $config = new DomainConfiguration(); + $config = new DomainConfiguration; $this->assertEquals(389, $config->get('port')); $this->assertNull($config->get('protocol')); @@ -88,7 +88,7 @@ public function test_all_options() public function test_get_all() { - $config = new DomainConfiguration(); + $config = new DomainConfiguration; $this->assertEquals([ 'hosts' => [], diff --git a/tests/Unit/ConnectionEventsTest.php b/tests/Unit/ConnectionEventsTest.php index ab111518..40b099e6 100644 --- a/tests/Unit/ConnectionEventsTest.php +++ b/tests/Unit/ConnectionEventsTest.php @@ -16,7 +16,7 @@ class ConnectionEventsTest extends TestCase { public function test_successful_connection_dispatches_proper_events() { - $ldap = (new LdapFake()) + $ldap = (new LdapFake) ->expect(LdapFake::operation('bind')->with('user', $this->anything())->andReturnResponse()); $conn = new Connection([ @@ -37,7 +37,7 @@ public function test_successful_connection_dispatches_proper_events() public function test_failed_connection_dispatches_proper_events() { - $ldap = (new LdapFake())->expect( + $ldap = (new LdapFake)->expect( LdapFake::operation('bind')->once()->andReturnErrorResponse() ); @@ -58,7 +58,7 @@ public function test_failed_connection_dispatches_proper_events() public function test_connection_retries_subsequent_hosts_until_successful() { - $ldap = (new LdapFake()) + $ldap = (new LdapFake) ->expect(LdapFake::operation('bind')->with('user')->twice()->andReturnErrorResponse()) ->expect(LdapFake::operation('bind')->with('user')->once()->andReturnResponse()) ->shouldReturnError("Can't contact LDAP server"); diff --git a/tests/Unit/ConnectionTest.php b/tests/Unit/ConnectionTest.php index b94390f0..b337dbd3 100644 --- a/tests/Unit/ConnectionTest.php +++ b/tests/Unit/ConnectionTest.php @@ -24,32 +24,32 @@ class ConnectionTest extends TestCase { public function test_connection_defaults() { - $conn = new Connection(); + $conn = new Connection; $this->assertInstanceOf(Ldap::class, $conn->getLdapConnection()); $this->assertInstanceOf(DomainConfiguration::class, $conn->getConfiguration()); - $this->assertEquals($conn->getConfiguration()->all(), (new DomainConfiguration())->all()); + $this->assertEquals($conn->getConfiguration()->all(), (new DomainConfiguration)->all()); } public function test_ldap_connection_can_be_set() { $conn = new Connection([]); - $conn->setLdapConnection($ldap = new LdapFake()); + $conn->setLdapConnection($ldap = new LdapFake); $this->assertEquals($ldap, $conn->getLdapConnection()); } public function test_configuration_can_be_set() { - $conn = new Connection(); + $conn = new Connection; $conn->setConfiguration(['hosts' => ['foo', 'bar']]); $this->assertEquals(['foo', 'bar'], $conn->getConfiguration()->get('hosts')); } public function test_connections_can_create_auth_instance() { - $this->assertInstanceOf(Guard::class, (new Connection())->auth()); + $this->assertInstanceOf(Guard::class, (new Connection)->auth()); } public function test_connections_creating_auth_instance_are_initialized() @@ -84,12 +84,12 @@ public function test_connections_creating_auth_instance_that_are_connected_are_n public function test_connections_can_create_queries() { - $this->assertInstanceOf(Builder::class, (new Connection())->query()); + $this->assertInstanceOf(Builder::class, (new Connection)->query()); } public function test_connections_can_be_replicated() { - $conn = new Connection(); + $conn = new Connection; $replicate = $conn->replicate(); @@ -147,7 +147,7 @@ public function test_ldap_connection_can_be_set_without_initialization() { $conn = new Connection(['hosts' => ['127.0.0.1'], 'port' => 123, 'use_ssl' => true]); - $ldap = new Ldap(); + $ldap = new Ldap; $this->assertEquals('', $ldap->getHost()); @@ -158,12 +158,12 @@ public function test_ldap_connection_can_be_set_without_initialization() public function test_is_connected() { - $ldap = (new LdapFake()) + $ldap = (new LdapFake) ->expect(LdapFake::operation('isBound')->once()->andReturnTrue()); $this->assertTrue((new Connection([], $ldap))->isConnected()); - $ldap = (new LdapFake()) + $ldap = (new LdapFake) ->expect(LdapFake::operation('isBound')->once()->andReturnFalse()); $this->assertFalse((new Connection([], $ldap))->isConnected()); @@ -171,7 +171,7 @@ public function test_is_connected() public function test_reconnect_initializes_connection() { - $ldap = (new LdapFake()) + $ldap = (new LdapFake) ->expect(LdapFake::operation('close')->once()->andReturnTrue()) ->expect(LdapFake::operation('ssl')->twice()->andReturnTrue()) ->expect(LdapFake::operation('bind')->once()->with('foo', 'bar')->andReturnResponse()); @@ -190,21 +190,21 @@ public function test_reconnect_initializes_connection() public function test_auth_username_failure() { - $conn = new Connection(); + $conn = new Connection; $this->expectException(UsernameRequiredException::class); $conn->auth()->attempt('', 'password'); } public function test_auth_password_failure() { - $conn = new Connection(); + $conn = new Connection; $this->expectException(PasswordRequiredException::class); $conn->auth()->attempt('username', ''); } public function test_auth_failure() { - $ldap = (new LdapFake()) + $ldap = (new LdapFake) ->expect(LdapFake::operation('bind')->once()->with('username', 'password')->andReturnErrorResponse()) ->expect(LdapFake::operation('bind')->once()->with('foo', 'bar')->andReturnResponse()); @@ -219,7 +219,7 @@ public function test_auth_failure() public function test_auth_passes_with_rebind() { - $ldap = (new LdapFake()) + $ldap = (new LdapFake) ->expect(LdapFake::operation('bind')->once()->with('username', 'password')->andReturnResponse()) ->expect(LdapFake::operation('bind')->once()->with('foo', 'bar')->andReturnResponse()); @@ -236,7 +236,7 @@ public function test_auth_rebind_failure() { $this->expectException(BindException::class); - $ldap = (new LdapFake()) + $ldap = (new LdapFake) ->expect(LdapFake::operation('bind')->once()->with('username', 'password')->andReturnResponse()) ->expect(LdapFake::operation('bind')->once()->with('foo', 'bar')->andReturnErrorResponse()); @@ -250,7 +250,7 @@ public function test_auth_rebind_failure() public function test_auth_passes_without_rebind() { - $ldap = (new LdapFake()) + $ldap = (new LdapFake) ->expect(LdapFake::operation('bind')->once()->with('username', 'password')->andReturnResponse()); $conn = new Connection([ @@ -264,7 +264,7 @@ public function test_auth_passes_without_rebind() public function test_connections_are_setup() { - $ldap = (new LdapFake()) + $ldap = (new LdapFake) ->expect([ LdapFake::operation('setOption')->with(LDAP_OPT_PROTOCOL_VERSION, 3)->once()->andReturnTrue(), LdapFake::operation('setOption')->with(LDAP_OPT_NETWORK_TIMEOUT, 5)->once()->andReturnTrue(), @@ -276,7 +276,7 @@ public function test_connections_are_setup() public function test_reconnect() { - $ldap = (new LdapFake()) + $ldap = (new LdapFake) ->expect(LdapFake::operation('close')->once()->andReturnTrue()) ->expect(LdapFake::operation('connect')->twice()->andReturnTrue()) ->expect(LdapFake::operation('bind')->once()->with('foo', 'bar')->andReturnResponse()); @@ -291,7 +291,7 @@ public function test_reconnect() public function test_ldap_operations_can_be_executed_with_connections() { - $ldap = (new LdapFake()) + $ldap = (new LdapFake) ->expect(LdapFake::operation('bind')->andReturnResponse()); $conn = new Connection([], $ldap); @@ -310,7 +310,7 @@ public function test_ldap_operations_can_be_executed_with_connections() public function test_ran_ldap_operations_are_retried_when_connection_is_lost() { - $ldap = (new LdapFake()) + $ldap = (new LdapFake) ->expect(LdapFake::operation('close')->times(3)->andReturnTrue()) ->expect(LdapFake::operation('connect')->times(4)->andReturnTrue()) ->expect(LdapFake::operation('bind')->andReturnResponse()); @@ -343,18 +343,18 @@ public function test_ran_ldap_operations_are_retried_when_connection_is_lost() public function test_ran_ldap_operations_are_not_retried_when_other_exception_is_thrown() { - $conn = new Connection(); + $conn = new Connection; $this->expectException(\Exception::class); $conn->run(function () { - throw new \Exception(); + throw new \Exception; }); } public function test_exception_is_transformed_when_already_exists_error_is_returned() { - $ldap = (new LdapFake())->expect(['bind' => new LdapResultResponse()]); + $ldap = (new LdapFake)->expect(['bind' => new LdapResultResponse]); $conn = new Connection([], $ldap); @@ -367,7 +367,7 @@ public function test_exception_is_transformed_when_already_exists_error_is_retur public function test_exception_is_transformed_when_insufficient_access_error_is_returned() { - $ldap = (new LdapFake())->expect(['bind' => new LdapResultResponse()]); + $ldap = (new LdapFake)->expect(['bind' => new LdapResultResponse]); $conn = new Connection([], $ldap); @@ -380,7 +380,7 @@ public function test_exception_is_transformed_when_insufficient_access_error_is_ public function test_exception_is_transformed_when_constraint_violation_error_is_returned() { - $ldap = (new LdapFake())->expect(['bind' => new LdapResultResponse()]); + $ldap = (new LdapFake)->expect(['bind' => new LdapResultResponse]); $conn = new Connection([], $ldap); diff --git a/tests/Unit/ContainerTest.php b/tests/Unit/ContainerTest.php index 4951aebc..e5a40f71 100644 --- a/tests/Unit/ContainerTest.php +++ b/tests/Unit/ContainerTest.php @@ -22,7 +22,7 @@ public function test_get_instance() public function test_set_as_global() { - $container = new Container(); + $container = new Container; $container->setAsGlobal(); @@ -33,8 +33,8 @@ public function test_adding_connections() { $container = Container::getInstance(); - $container->addConnection($default = new Connection()); - $container->addConnection($other = new Connection(), 'other'); + $container->addConnection($default = new Connection); + $container->addConnection($other = new Connection, 'other'); $this->assertSame($default, $container->getDefaultConnection()); $this->assertSame($other, $container->getConnection('other')); @@ -44,8 +44,8 @@ public function test_getting_connections() { $container = Container::getInstance(); - $container->addConnection(new Connection()); - $container->addConnection(new Connection(), 'other'); + $container->addConnection(new Connection); + $container->addConnection(new Connection, 'other'); $this->assertInstanceOf(Connection::class, $container->getDefaultConnection()); $this->assertInstanceOf(Connection::class, $container->getConnection('default')); @@ -61,7 +61,7 @@ public function test_getting_default_connections() { $container = Container::getInstance(); - $container->addConnection(new Connection()); + $container->addConnection(new Connection); $this->assertInstanceOf(Connection::class, $container->getDefaultConnection()); $this->assertInstanceOf(Connection::class, Container::getConnection('default')); @@ -85,7 +85,7 @@ public function test_setting_default_connections() $container->setDefaultConnection('other'); - $container->addConnection(new Connection()); + $container->addConnection(new Connection); $this->assertInstanceOf(Connection::class, $container->getConnection('other')); $this->assertInstanceOf(Connection::class, $container->getDefaultConnection()); @@ -103,11 +103,11 @@ public function test_connection_existence() $this->assertFalse($container->hasConnection('default')); - $container->addConnection(new Connection()); + $container->addConnection(new Connection); $this->assertTrue($container->hasConnection('default')); - $container->addConnection(new Connection(), 'other'); + $container->addConnection(new Connection, 'other'); $this->assertTrue($container->hasConnection('other')); } @@ -116,8 +116,8 @@ public function test_removing_connections() { $container = Container::getNewInstance(); - $container->addConnection(new Connection()); - $container->addConnection(new Connection(), 'other'); + $container->addConnection(new Connection); + $container->addConnection(new Connection, 'other'); $container->removeConnection('non-existent'); @@ -139,8 +139,8 @@ public function test_getting_all_connections() $container = Container::getNewInstance(); $connections = [ - 'default' => new Connection(), - 'other' => new Connection(), + 'default' => new Connection, + 'other' => new Connection, ]; $container->addConnection($connections['default']); @@ -153,7 +153,7 @@ public function test_logging_takes_place_after_instance_is_created() { $container = Container::getInstance(); - $event = new Binding(new Ldap(), 'username', 'password'); + $event = new Binding(new Ldap, 'username', 'password'); $dispatcher = $container->getDispatcher(); @@ -193,7 +193,7 @@ public function test_setting_container_logger_registers_event_listeners() $this->assertCount(0, $dispatcher->getListeners('LdapRecord\Query\Events\*')); $this->assertCount(0, $dispatcher->getListeners('LdapRecord\Models\Events\*')); - $container->setLogger(new NullLogger()); + $container->setLogger(new NullLogger); $this->assertCount(1, $dispatcher->getListeners('LdapRecord\Auth\Events\*')); $this->assertCount(1, $dispatcher->getListeners('LdapRecord\Query\Events\*')); diff --git a/tests/Unit/Events/DispatcherTest.php b/tests/Unit/Events/DispatcherTest.php index 92e93d4b..0f2b24a8 100644 --- a/tests/Unit/Events/DispatcherTest.php +++ b/tests/Unit/Events/DispatcherTest.php @@ -12,7 +12,7 @@ public function test_event_execution() { unset($_SERVER['__event.test']); - $d = new Dispatcher(); + $d = new Dispatcher; $d->listen('foo', function ($foo) { $_SERVER['__event.test'] = $foo; @@ -27,7 +27,7 @@ public function test_halting_event_execution() { unset($_SERVER['__event.test']); - $d = new Dispatcher(); + $d = new Dispatcher; $d->listen('foo', function ($foo) { $this->assertTrue(true); @@ -46,7 +46,7 @@ public function test_wildcard_listeners() { unset($_SERVER['__event.test']); - $d = new Dispatcher(); + $d = new Dispatcher; $d->listen('foo.bar', function () { $_SERVER['__event.test'] = 'regular'; @@ -69,7 +69,7 @@ public function test_wildcard_listeners_cache_flushing() { unset($_SERVER['__event.test']); - $d = new Dispatcher(); + $d = new Dispatcher; $d->listen('foo.*', function () { $_SERVER['__event.test'] = 'cached_wildcard'; @@ -92,7 +92,7 @@ public function test_listeners_can_be_removed() { unset($_SERVER['__event.test']); - $d = new Dispatcher(); + $d = new Dispatcher; $d->listen('foo', function () { $_SERVER['__event.test'] = 'foo'; @@ -109,7 +109,7 @@ public function test_wildcard_listeners_can_be_removed() { unset($_SERVER['__event.test']); - $d = new Dispatcher(); + $d = new Dispatcher; $d->listen('foo.*', function () { $_SERVER['__event.test'] = 'foo'; @@ -124,7 +124,7 @@ public function test_wildcard_listeners_can_be_removed() public function test_listeners_can_be_found() { - $d = new Dispatcher(); + $d = new Dispatcher; $this->assertFalse($d->hasListeners('foo')); @@ -137,7 +137,7 @@ public function test_listeners_can_be_found() public function test_wildcard_listeners_can_be_found() { - $d = new Dispatcher(); + $d = new Dispatcher; $this->assertFalse($d->hasListeners('foo.*')); @@ -150,7 +150,7 @@ public function test_wildcard_listeners_can_be_found() public function test_event_passed_first_to_wildcards() { - $d = new Dispatcher(); + $d = new Dispatcher; $d->listen('foo.*', function ($event, $data) { $this->assertEquals('foo.bar', $event); @@ -159,7 +159,7 @@ public function test_event_passed_first_to_wildcards() $d->fire('foo.bar', ['first', 'second']); - $d = new Dispatcher(); + $d = new Dispatcher; $d->listen('foo.bar', function ($first, $second) { $this->assertEquals('first', $first); @@ -173,13 +173,13 @@ public function test_classes_work() { unset($_SERVER['__event.test']); - $d = new Dispatcher(); + $d = new Dispatcher; $d->listen(ExampleEvent::class, function () { $_SERVER['__event.test'] = 'baz'; }); - $d->fire(new ExampleEvent()); + $d->fire(new ExampleEvent); $this->assertSame('baz', $_SERVER['__event.test']); } @@ -188,13 +188,13 @@ public function test_interfaces_work() { unset($_SERVER['__event.test']); - $d = new Dispatcher(); + $d = new Dispatcher; $d->listen(SomeEventInterface::class, function () { $_SERVER['__event.test'] = 'bar'; }); - $d->fire(new AnotherEvent()); + $d->fire(new AnotherEvent); $this->assertSame('bar', $_SERVER['__event.test']); } @@ -203,7 +203,7 @@ public function test_both_classes_and_interfaces_work() { unset($_SERVER['__event.test']); - $d = new Dispatcher(); + $d = new Dispatcher; $d->listen(AnotherEvent::class, function () { $_SERVER['__event.test1'] = 'fooo'; @@ -211,7 +211,7 @@ public function test_both_classes_and_interfaces_work() $d->listen(SomeEventInterface::class, ExampleListener::class); - $d->fire(new AnotherEvent()); + $d->fire(new AnotherEvent); $this->assertSame('fooo', $_SERVER['__event.test1']); $this->assertSame('baar', $_SERVER['__event.test2']); diff --git a/tests/Unit/Exceptions/ConstraintViolationExceptionTest.php b/tests/Unit/Exceptions/ConstraintViolationExceptionTest.php index 28f11982..c131a2a2 100644 --- a/tests/Unit/Exceptions/ConstraintViolationExceptionTest.php +++ b/tests/Unit/Exceptions/ConstraintViolationExceptionTest.php @@ -10,7 +10,7 @@ class ConstraintViolationExceptionTest extends TestCase { public function test_caused_by_password_policy() { - $e = new ConstraintViolationException(); + $e = new ConstraintViolationException; $this->assertFalse($e->causedByPasswordPolicy()); @@ -27,7 +27,7 @@ public function test_caused_by_password_policy() public function test_caused_by_incorrect_password() { - $e = new ConstraintViolationException(); + $e = new ConstraintViolationException; $this->assertFalse($e->causedByIncorrectPassword()); diff --git a/tests/Unit/FakeDirectoryTest.php b/tests/Unit/FakeDirectoryTest.php index b9d67c3e..605731aa 100644 --- a/tests/Unit/FakeDirectoryTest.php +++ b/tests/Unit/FakeDirectoryTest.php @@ -140,7 +140,7 @@ public function test_multiple_fake_directories() Container::addConnection(new Connection(['hosts' => ['bravo']]), 'bravo'); $alpha = DirectoryFake::setup('alpha'); - $alpha->getLdapConnection()->expect(['bind' => new LdapResultResponse()]); + $alpha->getLdapConnection()->expect(['bind' => new LdapResultResponse]); $bravo = DirectoryFake::setup('bravo'); $bravo->getLdapConnection()->expect(['bind' => new LdapResultResponse(1)]); diff --git a/tests/Unit/LdapTest.php b/tests/Unit/LdapTest.php index 1a9c5079..9537ee81 100644 --- a/tests/Unit/LdapTest.php +++ b/tests/Unit/LdapTest.php @@ -12,7 +12,7 @@ class LdapTest extends TestCase { public function test_construct_defaults() { - $ldap = new Ldap(); + $ldap = new Ldap; $this->assertFalse($ldap->isUsingTLS()); $this->assertFalse($ldap->isUsingSSL()); @@ -23,7 +23,7 @@ public function test_construct_defaults() public function test_host_arrays_are_properly_processed() { - $ldap = new LdapFake(); + $ldap = new LdapFake; $ldap->connect(['dc01', 'dc02'], $port = 500); @@ -32,7 +32,7 @@ public function test_host_arrays_are_properly_processed() public function test_host_strings_are_properly_created() { - $ldap = new LdapFake(); + $ldap = new LdapFake; $ldap->connect('dc01', $port = 500, 'foo://'); @@ -41,14 +41,14 @@ public function test_host_strings_are_properly_created() public function test_get_default_protocol() { - $ldap = new Ldap(); + $ldap = new Ldap; $this->assertEquals('ldap://', $ldap->getProtocol()); } public function test_get_protocol_ssl() { - $ldap = new Ldap(); + $ldap = new Ldap; $ldap->ssl(); @@ -57,7 +57,7 @@ public function test_get_protocol_ssl() public function test_get_host() { - $ldap = new Ldap(); + $ldap = new Ldap; $ldap->connect('192.168.1.1'); @@ -66,14 +66,14 @@ public function test_get_host() public function test_get_host_is_null_without_connecting() { - $ldap = new Ldap(); + $ldap = new Ldap; $this->assertNull($ldap->getHost()); } public function test_can_change_passwords() { - $ldap = new Ldap(); + $ldap = new Ldap; $ldap->ssl(); @@ -90,7 +90,7 @@ public function test_can_change_passwords() public function test_set_options() { - $ldap = (new LdapFake())->expect([ + $ldap = (new LdapFake)->expect([ LdapFake::operation('setOption')->once()->with(1, 'value')->andReturnTrue(), LdapFake::operation('setOption')->once()->with(2, 'value')->andReturnTrue(), ]); @@ -109,7 +109,7 @@ public function test_get_detailed_error_returns_null_when_error_number_is_zero() public function test_is_secure_after_binding_with_an_ssl_connection() { - $ldap = (new LdapFake())->expect([ + $ldap = (new LdapFake)->expect([ LdapFake::operation('bind')->once()->andReturnResponse(), ]); @@ -124,7 +124,7 @@ public function test_is_secure_after_binding_with_an_ssl_connection() public function test_is_secure_after_starting_tls() { - $ldap = (new LdapFake())->expect([ + $ldap = (new LdapFake)->expect([ LdapFake::operation('startTLS')->once()->andReturnTrue(), ]); @@ -137,7 +137,7 @@ public function test_is_secure_after_starting_tls() public function test_is_secure_after_starting_tls_but_failing_bind() { - $ldap = (new LdapFake())->expect([ + $ldap = (new LdapFake)->expect([ LdapFake::operation('startTLS')->once()->andReturnTrue(), LdapFake::operation('bind')->once()->andReturnResponse(1), ]); diff --git a/tests/Unit/Log/EventLoggerTest.php b/tests/Unit/Log/EventLoggerTest.php index 841ad882..4c3864f2 100644 --- a/tests/Unit/Log/EventLoggerTest.php +++ b/tests/Unit/Log/EventLoggerTest.php @@ -17,7 +17,7 @@ class EventLoggerTest extends TestCase { public function test_auth_events_are_logged() { - $ldap = new LdapFake(); + $ldap = new LdapFake; $ldap->connect('localhost'); @@ -40,7 +40,7 @@ public function test_failed_auth_event_reports_result() $ldap->connect('localhost'); - $event = new Failed($ldap, 'jdoe@acme.org', 'super-secret', new BindException()); + $event = new Failed($ldap, 'jdoe@acme.org', 'super-secret', new BindException); $logger = m::mock(LoggerInterface::class); diff --git a/tests/Unit/Models/ActiveDirectory/GroupTest.php b/tests/Unit/Models/ActiveDirectory/GroupTest.php index b57446da..06717b22 100644 --- a/tests/Unit/Models/ActiveDirectory/GroupTest.php +++ b/tests/Unit/Models/ActiveDirectory/GroupTest.php @@ -18,7 +18,7 @@ protected function setUp(): void public function test_rid_accessor_works() { - $group = new Group(); + $group = new Group; $this->assertEmpty($group->rid); $group = new Group(['objectsid' => 'S-1-5']); @@ -33,7 +33,7 @@ public function test_rid_accessor_works() public function test_primary_group_members_query() { - $group = new Group(); + $group = new Group; $group->setRawAttributes(['objectsid' => 'S-1-5-2141378235-513']); diff --git a/tests/Unit/Models/ActiveDirectory/ModelHasOnePrimaryGroupTest.php b/tests/Unit/Models/ActiveDirectory/ModelHasOnePrimaryGroupTest.php index e20bd212..e7f3b21c 100644 --- a/tests/Unit/Models/ActiveDirectory/ModelHasOnePrimaryGroupTest.php +++ b/tests/Unit/Models/ActiveDirectory/ModelHasOnePrimaryGroupTest.php @@ -19,7 +19,7 @@ protected function setUp(): void public function test_attach_sets_users_primary_group_id() { - $user = new UserSaveModelStub(); + $user = new UserSaveModelStub; $group = new Group(['objectsid' => 'S-1-111-222-513']); @@ -42,7 +42,5 @@ public function test_detach_clears_users_primary_group_id() class UserSaveModelStub extends User { - public function save(array $attributes = []): void - { - } + public function save(array $attributes = []): void {} } diff --git a/tests/Unit/Models/ActiveDirectory/ModelTest.php b/tests/Unit/Models/ActiveDirectory/ModelTest.php index 9652fe06..cfc34bc0 100644 --- a/tests/Unit/Models/ActiveDirectory/ModelTest.php +++ b/tests/Unit/Models/ActiveDirectory/ModelTest.php @@ -83,7 +83,7 @@ public function test_restore_returns_false_when_object_is_not_deleted() public function test_restore() { - $m = (new TestModelRestoreStub())->setRawAttributes([ + $m = (new TestModelRestoreStub)->setRawAttributes([ 'isdeleted' => ['true'], 'dn' => ['CN=John Doe\0ADEL:0eeaf35f-a619-4435-a2c7-d99b58dfcb77,CN=Deleted Objects,DC=local,DC=com'], ]); diff --git a/tests/Unit/Models/Attributes/AccountControlTest.php b/tests/Unit/Models/Attributes/AccountControlTest.php index 4d471968..24051466 100644 --- a/tests/Unit/Models/Attributes/AccountControlTest.php +++ b/tests/Unit/Models/Attributes/AccountControlTest.php @@ -9,7 +9,7 @@ class AccountControlTest extends TestCase { public function test_default_value_is_zero() { - $ac = new AccountControl(); + $ac = new AccountControl; $this->assertEquals(0, $ac->getValue()); $this->assertIsInt($ac->getValue()); @@ -17,7 +17,7 @@ public function test_default_value_is_zero() public function test_all_options_are_applied_correctly() { - $ac = new AccountControl(); + $ac = new AccountControl; $values = array_values($ac->getAllFlags()); @@ -75,7 +75,7 @@ public function test_all_options_are_applied_correctly() public function test_can_be_casted_to_int() { - $ac = new AccountControl(); + $ac = new AccountControl; $this->assertEquals(0, $ac->__toInt()); $this->assertEquals(0, $ac->getValue()); @@ -84,7 +84,7 @@ public function test_can_be_casted_to_int() public function test_can_be_casted_to_string() { - $ac = new AccountControl(); + $ac = new AccountControl; $this->assertEquals('0', (string) $ac); $this->assertEquals('0', $ac->__toString()); @@ -107,7 +107,7 @@ public function test_multiple_flags_can_be_applied() public function test_has() { - $ac = new AccountControl(); + $ac = new AccountControl; $ac ->setAccountIsLocked() @@ -123,7 +123,7 @@ public function test_has() public function test_doesnt_have() { - $ac = new AccountControl(); + $ac = new AccountControl; $ac ->setAccountIsLocked() @@ -139,7 +139,7 @@ public function test_doesnt_have() public function test_values_are_overwritten() { - $ac = new AccountControl(); + $ac = new AccountControl; $ac->setAccountIsNormal() ->setAccountIsNormal() @@ -150,7 +150,7 @@ public function test_values_are_overwritten() public function test_values_can_be_set() { - $ac = new AccountControl(); + $ac = new AccountControl; $ac->setAccountIsNormal()->setAccountIsDisabled(); @@ -165,7 +165,7 @@ public function test_values_can_be_set() public function test_values_can_be_added() { - $ac = new AccountControl(); + $ac = new AccountControl; // Values are overwritten. $ac->setFlag(AccountControl::ACCOUNTDISABLE); @@ -176,7 +176,7 @@ public function test_values_can_be_added() public function test_values_can_be_removed() { - $ac = new AccountControl(); + $ac = new AccountControl; $ac->setAccountIsNormal()->setAccountIsDisabled(); diff --git a/tests/Unit/Models/Attributes/BatchModificationTest.php b/tests/Unit/Models/Attributes/BatchModificationTest.php index 9975cad8..b97f1881 100644 --- a/tests/Unit/Models/Attributes/BatchModificationTest.php +++ b/tests/Unit/Models/Attributes/BatchModificationTest.php @@ -10,7 +10,7 @@ class BatchModificationTest extends TestCase { public function test_build_with_original() { - $modification = new BatchModification(); + $modification = new BatchModification; $modification->setOriginal('Test'); $modification->setAttribute('cn'); @@ -23,7 +23,7 @@ public function test_build_with_original() public function test_build_without_original() { - $modification = new BatchModification(); + $modification = new BatchModification; $modification->setAttribute('cn'); $modification->setValues(['New CN']); @@ -35,7 +35,7 @@ public function test_build_without_original() public function test_build_with_original_and_null_value() { - $modification = new BatchModification(); + $modification = new BatchModification; $modification->setOriginal('Test'); $modification->setAttribute('cn'); @@ -48,7 +48,7 @@ public function test_build_with_original_and_null_value() public function test_build_without_original_and_null_value() { - $modification = new BatchModification(); + $modification = new BatchModification; $modification->setAttribute('cn'); $modification->setValues([null]); @@ -62,7 +62,7 @@ public function test_build_with_added_value() { $original = ['foo', 'bar']; - $modification = new BatchModification(); + $modification = new BatchModification; $modification->setAttribute('member'); $modification->setOriginal($original); @@ -78,7 +78,7 @@ public function test_build_with_removed_value() { $original = ['foo', 'bar']; - $modification = new BatchModification(); + $modification = new BatchModification; $modification->setAttribute('member'); $modification->setOriginal($original); @@ -92,7 +92,7 @@ public function test_build_with_removed_value() public function test_get() { - $modification = new BatchModification(); + $modification = new BatchModification; $modification->setValues(['test']); $modification->setAttribute('cn'); @@ -111,14 +111,14 @@ public function test_set_type_invalid() { $this->expectException(\InvalidArgumentException::class); - $modification = new BatchModification(); + $modification = new BatchModification; $modification->setType(100); } public function test_set_values() { - $modification = new BatchModification(); + $modification = new BatchModification; $modification->setValues(['test']); @@ -127,7 +127,7 @@ public function test_set_values() public function test_set_type() { - $modification = new BatchModification(); + $modification = new BatchModification; $modification->setType(1); @@ -136,7 +136,7 @@ public function test_set_type() public function test_set_attribute() { - $modification = new BatchModification(); + $modification = new BatchModification; $modification->setAttribute('test'); @@ -145,7 +145,7 @@ public function test_set_attribute() public function test_set_original() { - $modification = new BatchModification(); + $modification = new BatchModification; $modification->setOriginal(['testing']); @@ -164,7 +164,7 @@ public function test_constructor() public function test_values_are_converted_to_strings() { - $class = new class() + $class = new class { public function __toString() { @@ -175,7 +175,7 @@ public function __toString() $modification = new BatchModification('attribute', 1, [ (int) 500, (float) 10.5, - new $class(), + new $class, ]); $this->assertIsString($modification->getValues()[0]); @@ -199,7 +199,7 @@ public function test_is_valid() public function test_is_not_valid() { // Empty modification - $mod1 = new BatchModification(); + $mod1 = new BatchModification; // Building a modification which only contains an attribute and empty type & value. $mod2 = new BatchModification('attribute'); @@ -211,10 +211,10 @@ public function test_is_not_valid() public function test_modification_values_are_converted_to_string() { - $mod = new BatchModification(); + $mod = new BatchModification; - $mod->setOriginal([(new AccountControl())->setAccountIsNormal()]); - $mod->setValues([(new AccountControl())->setAccountIsNormal()]); + $mod->setOriginal([(new AccountControl)->setAccountIsNormal()]); + $mod->setValues([(new AccountControl)->setAccountIsNormal()]); $this->assertIsString($mod->getOriginal()[0]); $this->assertIsString($mod->getValues()[0]); diff --git a/tests/Unit/Models/Attributes/DistinguishedNameBuilderTest.php b/tests/Unit/Models/Attributes/DistinguishedNameBuilderTest.php index 6161407e..966241ca 100644 --- a/tests/Unit/Models/Attributes/DistinguishedNameBuilderTest.php +++ b/tests/Unit/Models/Attributes/DistinguishedNameBuilderTest.php @@ -134,7 +134,7 @@ public function test_prepend() public function test_components_arrays_and_strings_can_be_passed_to_append_and_prepend() { - $dn = (new DistinguishedNameBuilder()) + $dn = (new DistinguishedNameBuilder) ->prepend([ 'cn=John Doe', ['dc', 'local'], @@ -144,7 +144,7 @@ public function test_components_arrays_and_strings_can_be_passed_to_append_and_p $this->assertEquals('cn=John Doe,dc=local,dc=com', $dn); - $dn = (new DistinguishedNameBuilder()) + $dn = (new DistinguishedNameBuilder) ->append([ 'cn=John Doe', ['dc', 'local'], diff --git a/tests/Unit/Models/Attributes/TimestampTest.php b/tests/Unit/Models/Attributes/TimestampTest.php index f1e0a5ff..bb50009c 100644 --- a/tests/Unit/Models/Attributes/TimestampTest.php +++ b/tests/Unit/Models/Attributes/TimestampTest.php @@ -32,7 +32,7 @@ public function test_converting_to_date_returns_date_objects() { $timestamp = new Timestamp(Timestamp::TYPE_LDAP); - $date = new DateTime(); + $date = new DateTime; $this->assertEquals($date, $timestamp->toDateTime($date)); } @@ -41,10 +41,10 @@ public function test_dates_can_be_converted_to_ldap_type() { $timestamp = new Timestamp(Timestamp::TYPE_LDAP); - $date = new DateTime(); + $date = new DateTime; $this->assertEquals($date->format('YmdHis\Z'), $timestamp->fromDateTime($date)); - $date = (new DateTime())->setTimezone(new \DateTimeZone('EST')); + $date = (new DateTime)->setTimezone(new \DateTimeZone('EST')); $this->assertEquals($date->format('YmdHis').'-0500', $timestamp->fromDateTime($date)); } @@ -52,10 +52,10 @@ public function test_dates_can_be_converted_to_windows_type() { $timestamp = new Timestamp(Timestamp::TYPE_WINDOWS); - $date = new DateTime(); + $date = new DateTime; $this->assertEquals($date->format('YmdHis.0\Z'), $timestamp->fromDateTime($date)); - $date = (new DateTime())->setTimezone(new \DateTimeZone('EST')); + $date = (new DateTime)->setTimezone(new \DateTimeZone('EST')); $this->assertEquals($date->format('YmdHis.0').'-0500', $timestamp->fromDateTime($date)); } @@ -63,7 +63,7 @@ public function test_dates_can_be_converted_to_windows_integer_type() { $timestamp = new Timestamp(Timestamp::TYPE_WINDOWS_INT); - $date = (new DateTime())->setTimestamp($this->unixTimestamp); + $date = (new DateTime)->setTimestamp($this->unixTimestamp); $this->assertEquals('132460789290000000', $timestamp->fromDateTime($date)); } diff --git a/tests/Unit/Models/ModelAccessorMutatorTest.php b/tests/Unit/Models/ModelAccessorMutatorTest.php index 03df46fe..ad51bb14 100644 --- a/tests/Unit/Models/ModelAccessorMutatorTest.php +++ b/tests/Unit/Models/ModelAccessorMutatorTest.php @@ -12,9 +12,9 @@ class ModelAccessorMutatorTest extends TestCase { public function test_model_uses_accessor() { - $model = new ModelAccessorStub(); + $model = new ModelAccessorStub; - $date = new DateTime(); + $date = new DateTime; $model->createtimestamp = $date; @@ -29,14 +29,14 @@ public function test_model_uses_accessor() public function test_accessor_is_used_when_attribute_is_null() { - $model = new ModelAccessorStub(); + $model = new ModelAccessorStub; $this->assertEquals('zax', $model->zax); } public function test_model_uses_accessor_with_hyphen() { - $model = new ModelAccessorStub(); + $model = new ModelAccessorStub; $this->assertEquals('baz-other', $model->getAttribute('foo-bar')); $this->assertEquals(['baz'], $model->toArray()['foo-bar']); @@ -49,7 +49,7 @@ public function test_model_uses_accessor_with_hyphen() public function test_model_uses_mutator() { - $model = new ModelMutatorStub(); + $model = new ModelMutatorStub; $model->foo = 'setter-'; @@ -61,7 +61,7 @@ public function test_model_uses_mutator() public function test_models_uses_mutator_with_hypen() { - $model = new ModelMutatorStub(); + $model = new ModelMutatorStub; $model->foo_bar = 'setter'; @@ -75,8 +75,8 @@ public function test_models_uses_mutator_with_hypen() public function test_models_mutate_dates_to_ldap_type() { - $model = new ModelDateMutatorStub(); - $date = new Carbon(); + $model = new ModelDateMutatorStub; + $date = new Carbon; $model->createtimestamp = $date; @@ -88,8 +88,8 @@ public function test_models_mutate_dates_to_ldap_type() public function test_models_mutate_dates_to_windows_type() { - $model = new ModelDateMutatorStub(); - $date = new Carbon(); + $model = new ModelDateMutatorStub; + $date = new Carbon; $model->whenchanged = $date; @@ -101,8 +101,8 @@ public function test_models_mutate_dates_to_windows_type() public function test_models_mutate_dates_to_windows_integer_type() { - $model = new ModelDateMutatorStub(); - $date = new Carbon(); + $model = new ModelDateMutatorStub; + $date = new Carbon; $model->accountexpires = $date; @@ -118,7 +118,7 @@ public function test_models_mutate_dates_to_windows_integer_type() public function test_models_mutate_from_ldap_type_to_date() { - $model = new ModelDateAccessorStub(); + $model = new ModelDateAccessorStub; $this->assertInstanceOf(Carbon::class, $model->createtimestamp); $this->assertInstanceOf(Carbon::class, $model->CreateTimestamp); @@ -134,7 +134,7 @@ public function test_models_mutate_from_ldap_type_to_date() public function test_models_mutate_from_windows_type_to_date() { - $model = new ModelDateAccessorStub(); + $model = new ModelDateAccessorStub; $this->assertInstanceOf(Carbon::class, $model->whenchanged); $this->assertInstanceOf(Carbon::class, $model->WhenChanged); @@ -150,7 +150,7 @@ public function test_models_mutate_from_windows_type_to_date() public function test_models_mutate_from_windows_integer_type_to_date() { - $model = new ModelDateAccessorStub(); + $model = new ModelDateAccessorStub; $this->assertInstanceOf(Carbon::class, $model->accountexpires); $this->assertInstanceOf(Carbon::class, $model->AccountExpires); diff --git a/tests/Unit/Models/ModelAttributeAppendsTest.php b/tests/Unit/Models/ModelAttributeAppendsTest.php index 39c4812b..5f2977c2 100644 --- a/tests/Unit/Models/ModelAttributeAppendsTest.php +++ b/tests/Unit/Models/ModelAttributeAppendsTest.php @@ -11,17 +11,17 @@ public function test_accessors_are_appended() { $this->assertEquals([ 'foo' => ['bar'], - ], (new ModelAttributeAppendsTestStub())->toArray()); + ], (new ModelAttributeAppendsTestStub)->toArray()); } public function test_get_appends() { - $this->assertEquals(['foo'], (new ModelAttributeAppendsTestStub())->getAppends()); + $this->assertEquals(['foo'], (new ModelAttributeAppendsTestStub)->getAppends()); } public function test_set_appends() { - $model = new ModelAttributeAppendsTestStub(); + $model = new ModelAttributeAppendsTestStub; $model->setAppends(['bar']); @@ -30,12 +30,12 @@ public function test_set_appends() public function test_has_appended() { - $this->assertTrue((new ModelAttributeAppendsTestStub())->hasAppended('foo')); + $this->assertTrue((new ModelAttributeAppendsTestStub)->hasAppended('foo')); } public function test_appends_with_hyphenated_property() { - $model = new ModelAttributeAppendsTestStub(); + $model = new ModelAttributeAppendsTestStub; $model->setAppends(['foo-bar']); diff --git a/tests/Unit/Models/ModelEventTest.php b/tests/Unit/Models/ModelEventTest.php index 8dd2a07b..b6bab10c 100644 --- a/tests/Unit/Models/ModelEventTest.php +++ b/tests/Unit/Models/ModelEventTest.php @@ -33,7 +33,7 @@ public function test_save_fires_saving_and_create_events() Container::getInstance()->setDispatcher($dispatcher); - (new ModelEventSaveStub())->save(); + (new ModelEventSaveStub)->save(); } public function test_save_quietly_does_not_fire_any_events() @@ -44,7 +44,7 @@ public function test_save_quietly_does_not_fire_any_events() Container::getInstance()->setDispatcher($dispatcher); - (new ModelEventSaveStub())->saveQuietly(); + (new ModelEventSaveStub)->saveQuietly(); $this->assertEquals($dispatcher, Container::getInstance()->getDispatcher()); } @@ -71,7 +71,7 @@ public function test_create_fires_events() ) ->andReturnTrue(); - $ldap = (new LdapFake())->expect(['isBound' => true, $expectation]); + $ldap = (new LdapFake)->expect(['isBound' => true, $expectation]); $query = new Builder(new Connection([], $ldap)); @@ -109,7 +109,7 @@ public function test_updating_model_fires_events() ], ])->andReturnTrue(); - $ldap = (new LdapFake())->expect(['isBound' => true, $modifyBatchExpectation]); + $ldap = (new LdapFake)->expect(['isBound' => true, $modifyBatchExpectation]); $query = new Builder(new Connection([], $ldap)); @@ -133,7 +133,7 @@ public function test_deleting_model_fires_events() $expectation = LdapFake::operation('delete')->once()->with('cn=foo,dc=bar,dc=baz')->andReturnTrue(); - $ldap = (new LdapFake())->expect(['isBound' => true, $expectation]); + $ldap = (new LdapFake)->expect(['isBound' => true, $expectation]); $query = new Builder(new Connection([], $ldap)); @@ -166,7 +166,7 @@ class ModelEventSaveStub extends Model { public function newQueryWithoutScopes(): ModelQueryBuilderSaveStub { - return (new ModelQueryBuilderSaveStub(new Connection()))->setModel($this); + return (new ModelQueryBuilderSaveStub(new Connection))->setModel($this); } public function refresh(): bool diff --git a/tests/Unit/Models/ModelHasManyInTest.php b/tests/Unit/Models/ModelHasManyInTest.php index 28021e19..8ea9e39e 100644 --- a/tests/Unit/Models/ModelHasManyInTest.php +++ b/tests/Unit/Models/ModelHasManyInTest.php @@ -27,13 +27,13 @@ public function test_get() $query->shouldReceive('select')->once()->with(['*'])->andReturnSelf(); $query->shouldReceive('find')->once()->with('baz')->andReturn(new Entry); - $model = new ModelHasManyInStub(); + $model = new ModelHasManyInStub; $model->bar = ['baz']; $collection = $model->relation($query)->get(); $this->assertInstanceOf(Collection::class, $collection); - $this->assertEquals(new Entry(), $collection->first()); + $this->assertEquals(new Entry, $collection->first()); } public function test_get_with_alternate_foreign_key() @@ -42,13 +42,13 @@ public function test_get_with_alternate_foreign_key() $query->shouldReceive('select')->once()->with(['*'])->andReturnSelf(); $query->shouldReceive('findBy')->once()->with('foreign', 'baz')->andReturn(new Entry); - $model = new ModelHasManyInStub(); + $model = new ModelHasManyInStub; $model->bar = ['baz']; $collection = $model->relation($query, 'foreign')->get(); $this->assertInstanceOf(Collection::class, $collection); - $this->assertEquals(new Entry(), $collection->first()); + $this->assertEquals(new Entry, $collection->first()); } } diff --git a/tests/Unit/Models/ModelHasManyTest.php b/tests/Unit/Models/ModelHasManyTest.php index 24521f07..732420a3 100644 --- a/tests/Unit/Models/ModelHasManyTest.php +++ b/tests/Unit/Models/ModelHasManyTest.php @@ -28,7 +28,7 @@ protected function setUp(): void public function test_relation_name_is_guessed() { - $this->assertEquals('relation', (new ModelHasManyStub())->relation()->getRelationName()); + $this->assertEquals('relation', (new ModelHasManyStub)->relation()->getRelationName()); } public function test_get_results() @@ -37,13 +37,13 @@ public function test_get_results() $parent = $relation->getParent(); $parent->shouldReceive('getDn')->andReturn('foo'); - $parent->shouldReceive('newCollection')->once()->andReturn(new Collection()); + $parent->shouldReceive('newCollection')->once()->andReturn(new Collection); $query = $relation->getQuery(); $query->shouldReceive('escape')->once()->with('foo')->andReturn(new EscapedValue('foo')); $query->shouldReceive('getSelects')->once()->withNoArgs()->andReturn(['*']); $query->shouldReceive('whereRaw')->once()->with('member', '=', 'foo')->andReturnSelf(); - $query->shouldReceive('paginate')->once()->with(1000)->andReturn(new Collection([$related = new Entry()])); + $query->shouldReceive('paginate')->once()->with(1000)->andReturn(new Collection([$related = new Entry])); $collection = $relation->getResults(); @@ -57,10 +57,10 @@ public function test_get_recursive_results() $parent = $relation->getParent(); $parent->shouldReceive('getDn')->andReturn('foo'); - $parent->shouldReceive('newCollection')->once()->andReturn(new Collection()); + $parent->shouldReceive('newCollection')->once()->andReturn(new Collection); $child = m::mock(HasMany::class)->shouldAllowMockingProtectedMethods(); - $child->shouldReceive('getRecursiveResults')->once()->with(['bar'])->andReturn(new Collection([new Entry()])); + $child->shouldReceive('getRecursiveResults')->once()->with(['bar'])->andReturn(new Collection([new Entry])); $related = m::mock(ModelHasManyStub::class)->makePartial(); $related->shouldReceive('getDn')->andReturn('bar'); @@ -104,8 +104,7 @@ public function test_chunk() return true; })); - $relation->chunk(1000, function () { - }); + $relation->chunk(1000, function () {}); } public function test_recursive_chunk() @@ -137,8 +136,7 @@ public function test_recursive_chunk() return true; })); - $relation->recursive()->chunk(1000, function () { - }); + $relation->recursive()->chunk(1000, function () {}); } public function test_page_size_can_be_set() @@ -147,7 +145,7 @@ public function test_page_size_can_be_set() $parent = $relation->getParent(); $parent->shouldReceive('getDn')->andReturn('foo'); - $parent->shouldReceive('newCollection')->once()->andReturn(new Collection()); + $parent->shouldReceive('newCollection')->once()->andReturn(new Collection); $relation->setPageSize(500); @@ -155,7 +153,7 @@ public function test_page_size_can_be_set() $query->shouldReceive('escape')->once()->with('foo')->andReturn(new EscapedValue('foo')); $query->shouldReceive('getSelects')->once()->withNoArgs()->andReturn(['*']); $query->shouldReceive('whereRaw')->once()->with('member', '=', 'foo')->andReturnSelf(); - $query->shouldReceive('paginate')->once()->with(500)->andReturn(new Collection()); + $query->shouldReceive('paginate')->once()->with(500)->andReturn(new Collection); $this->assertInstanceOf(Collection::class, $relation->getResults()); } @@ -208,7 +206,7 @@ public function test_detaching_all() $parent = $relation->getParent(); $parent->shouldReceive('getDn')->andReturn('foo'); - $parent->shouldReceive('newCollection')->once()->andReturn(new Collection()); + $parent->shouldReceive('newCollection')->once()->andReturn(new Collection); $related = m::mock(Entry::class)->makePartial(); $related->shouldReceive('getObjectClasses')->once()->andReturn([]); @@ -229,7 +227,7 @@ public function test_only_related_with_many_relation_object_classes() { $this->assertEquals( '(&(|(objectclass=top)(objectclass=person)(objectclass=organizationalperson)(objectclass=user))(|(objectclass=top)(objectclass=group)))', - (new ModelHasManyStubWithManyRelated())->relation()->onlyRelated()->getQuery()->getUnescapedQuery() + (new ModelHasManyStubWithManyRelated)->relation()->onlyRelated()->getQuery()->getUnescapedQuery() ); } @@ -237,7 +235,7 @@ public function test_only_related_with_no_relation_object_classes() { $this->assertEquals( '(objectclass=*)', - (new ModelHasManyStub())->relation()->onlyRelated()->getQuery()->getUnescapedQuery() + (new ModelHasManyStub)->relation()->onlyRelated()->getQuery()->getUnescapedQuery() ); } diff --git a/tests/Unit/Models/ModelHasManyUsingTest.php b/tests/Unit/Models/ModelHasManyUsingTest.php index cb105c35..bf4a84e8 100644 --- a/tests/Unit/Models/ModelHasManyUsingTest.php +++ b/tests/Unit/Models/ModelHasManyUsingTest.php @@ -21,7 +21,7 @@ public function test_attach() $relation->using($relation->getParent(), 'member'); - $related = new Entry(); + $related = new Entry; $related->setRawAttributes(['dn' => 'foo']); $relation->attach($related); @@ -38,7 +38,7 @@ public function test_detach() $relation->using($relation->getParent(), 'member'); - $related = new Entry(); + $related = new Entry; $related->setRawAttributes(['dn' => 'foo']); $relation->detach($related); diff --git a/tests/Unit/Models/ModelHasOneTest.php b/tests/Unit/Models/ModelHasOneTest.php index af009e53..d261e0f3 100644 --- a/tests/Unit/Models/ModelHasOneTest.php +++ b/tests/Unit/Models/ModelHasOneTest.php @@ -27,7 +27,7 @@ public function test_get() $parent = $relation->getParent(); $parent->shouldReceive('getFirstAttribute')->once()->with('manager')->andReturn('foo'); - $parent->shouldReceive('newCollection')->once()->andReturn(new Collection([$related = new Entry()])); + $parent->shouldReceive('newCollection')->once()->andReturn(new Collection([$related = new Entry])); $query = $relation->getQuery(); $query->shouldReceive('select')->once()->with(['*'])->andReturnSelf(); @@ -40,7 +40,7 @@ public function test_attach() { $relation = $this->getRelation(); - $related = new Entry(); + $related = new Entry; $related->setDn('foo'); $parent = $relation->getParent(); diff --git a/tests/Unit/Models/ModelHiddenAttributesTest.php b/tests/Unit/Models/ModelHiddenAttributesTest.php index ae0d0851..c8383c41 100644 --- a/tests/Unit/Models/ModelHiddenAttributesTest.php +++ b/tests/Unit/Models/ModelHiddenAttributesTest.php @@ -10,7 +10,7 @@ class ModelHiddenAttributesTest extends TestCase { public function test_attributes_can_be_added_to_hidden_and_visible() { - $m = new Entry(); + $m = new Entry; $m->setVisible(['foo', 'bar']); $this->assertEquals(['foo', 'bar'], $m->getVisible()); diff --git a/tests/Unit/Models/ModelQueryTest.php b/tests/Unit/Models/ModelQueryTest.php index ee783433..9d1db72c 100644 --- a/tests/Unit/Models/ModelQueryTest.php +++ b/tests/Unit/Models/ModelQueryTest.php @@ -28,9 +28,9 @@ public function test_resolving_connections() $this->assertInstanceOf(Connection::class, Entry::resolveConnection()); - Container::addConnection(new Connection(), 'other'); + Container::addConnection(new Connection, 'other'); - $model = new Entry(); + $model = new Entry; $model->setConnection('other'); @@ -42,7 +42,7 @@ public function test_new_query() { Container::addConnection(new Connection); - $model = new Entry(); + $model = new Entry; $this->assertEquals($model, Entry::query()->getModel()); $this->assertEquals($model, $model->newQuery()->getModel()); @@ -52,7 +52,7 @@ public function test_new_query_without_scopes() { Container::addConnection(new Connection); - $model = new Entry(); + $model = new Entry; $query = $model->newQueryWithoutScopes(); @@ -105,7 +105,7 @@ public function test_find_queries_substitute_base_dn() public function test_on() { - Container::addConnection(new Connection(), 'other'); + Container::addConnection(new Connection, 'other'); $query = Entry::on('other'); @@ -170,7 +170,7 @@ public function test_create_with_substituted_base() LdapFake::operation('add')->once()->with('cn=foo,dc=foo,dc=bar')->andReturnTrue(), ); - $model = new Entry(); + $model = new Entry; $model->setDn('cn=foo,{base}'); $model->fill(['cn' => 'foo', 'objectclass' => 'bar']); @@ -199,7 +199,7 @@ public function test_add_attribute_without_existing_model() { $this->expectException(ModelDoesNotExistException::class); - $model = new Entry(); + $model = new Entry; $model->addAttribute('foo', 'bar'); } @@ -270,7 +270,7 @@ public function test_replace_attribute_without_existing_model() { $this->expectException(ModelDoesNotExistException::class); - $model = new Entry(); + $model = new Entry; $model->replaceAttribute('foo', 'bar'); } @@ -299,7 +299,7 @@ public function test_delete_without_existing_model() { $this->expectException(ModelDoesNotExistException::class); - $model = new Entry(); + $model = new Entry; $model->delete(); } @@ -347,7 +347,7 @@ public function test_delete_attribute_without_existing_model() { $this->expectException(ModelDoesNotExistException::class); - $model = new Entry(); + $model = new Entry; $model->delete(); } @@ -391,7 +391,7 @@ public function test_descendants_scope() { Container::addConnection(new Connection); - $model = new Entry(); + $model = new Entry; $model->setDn('ou=Users,dc=acme,dc=org'); $query = $model->descendants(); @@ -405,7 +405,7 @@ public function test_ancestors_scope() { Container::addConnection(new Connection); - $model = new Entry(); + $model = new Entry; $model->setDn('ou=Office,ou=Users,dc=acme,dc=org'); $query = $model->ancestors(); @@ -419,7 +419,7 @@ public function test_siblings_scope() { Container::addConnection(new Connection); - $model = new Entry(); + $model = new Entry; $model->setDn('ou=Users,dc=acme,dc=org'); $query = $model->siblings(); @@ -440,7 +440,7 @@ public function test_date_objects_are_converted_to_ldap_timestamps_in_where_clau { Container::addConnection(new Connection); - $datetime = new DateTime(); + $datetime = new DateTime; $query = ModelQueryDateConversionTest::query()->newInstance() ->whereRaw('standard', '=', $datetime) @@ -459,7 +459,7 @@ public function test_exception_is_thrown_when_date_objects_cannot_be_converted() $this->expectException(UnexpectedValueException::class); $this->expectExceptionMessage('Cannot convert field [non-existent-date]'); - Entry::query()->where('non-existent-date', new DateTime()); + Entry::query()->where('non-existent-date', new DateTime); } } @@ -483,7 +483,7 @@ public static function query(): Builder { $query = m::mock(Builder::class); $query->shouldReceive('select')->once()->with(['*'])->andReturnSelf(); - $query->shouldReceive('paginate')->once()->withNoArgs()->andReturn(new Collection()); + $query->shouldReceive('paginate')->once()->withNoArgs()->andReturn(new Collection); return $query; } diff --git a/tests/Unit/Models/ModelRelationTest.php b/tests/Unit/Models/ModelRelationTest.php index f8bac0ef..76b8bd77 100644 --- a/tests/Unit/Models/ModelRelationTest.php +++ b/tests/Unit/Models/ModelRelationTest.php @@ -27,7 +27,7 @@ public function test_has_parent() { $this->assertInstanceOf( ModelRelationTestStub::class, - (new ModelRelationTestStub())->relation()->getParent() + (new ModelRelationTestStub)->relation()->getParent() ); } @@ -35,7 +35,7 @@ public function test_has_relations() { $this->assertEquals( [RelatedModelTestStub::class], - (new ModelRelationTestStub())->relation()->getRelated() + (new ModelRelationTestStub)->relation()->getRelated() ); } @@ -43,7 +43,7 @@ public function test_has_query() { $this->assertInstanceOf( Builder::class, - (new ModelRelationTestStub())->relation()->getQuery() + (new ModelRelationTestStub)->relation()->getQuery() ); } @@ -51,12 +51,12 @@ public function test_has_default_model() { $this->assertEquals( Entry::class, - (new ModelRelationTestStub())->relation()->getDefaultModel() + (new ModelRelationTestStub)->relation()->getDefaultModel() ); $this->assertInstanceOf( Entry::class, - (new ModelRelationTestStub())->relation()->getNewDefaultModel() + (new ModelRelationTestStub)->relation()->getNewDefaultModel() ); } @@ -64,7 +64,7 @@ public function test_query_has_no_filters() { $this->assertEquals( ['and' => [], 'or' => [], 'raw' => []], - (new ModelRelationTestStub())->relation()->getQuery()->filters + (new ModelRelationTestStub)->relation()->getQuery()->filters ); } @@ -72,7 +72,7 @@ public function test_query_has_default_model() { $this->assertInstanceOf( Entry::class, - (new ModelRelationTestStub())->relation()->getQuery()->getModel() + (new ModelRelationTestStub)->relation()->getQuery()->getModel() ); } @@ -80,7 +80,7 @@ public function test_has_related_key() { $this->assertEquals( 'foo', - (new ModelRelationTestStub())->relation()->getRelationKey() + (new ModelRelationTestStub)->relation()->getRelationKey() ); } @@ -88,13 +88,13 @@ public function test_has_foreign_key() { $this->assertEquals( 'bar', - (new ModelRelationTestStub())->relation()->getForeignKey() + (new ModelRelationTestStub)->relation()->getForeignKey() ); } public function test_get() { - $collection = (new ModelRelationTestStub())->relation()->get('foo'); + $collection = (new ModelRelationTestStub)->relation()->get('foo'); $this->assertEmpty($collection); $this->assertInstanceOf(Collection::class, $collection); @@ -102,7 +102,7 @@ public function test_get() public function test_get_results() { - $relation = (new ModelRelationTestStub())->relation(); + $relation = (new ModelRelationTestStub)->relation(); $collection = $relation->get('foo'); $this->assertEmpty($collection); @@ -112,14 +112,14 @@ public function test_get_results() public function test_exists() { - $relation = (new ModelRelationTestStub())->relation(); + $relation = (new ModelRelationTestStub)->relation(); $this->assertFalse($relation->exists()); - $related = new Entry(); + $related = new Entry; $related->setDn('cn=foo,dc=local,dc=com'); - $unrelated = new Entry(); + $unrelated = new Entry; $unrelated->setDn('cn=bar,dc=local,dc=com'); $relation->setResults([$related]); @@ -141,14 +141,14 @@ public function test_exists() public function test_contains() { - $relation = (new ModelRelationTestStub())->relation(); + $relation = (new ModelRelationTestStub)->relation(); $this->assertFalse($relation->contains('foo')); - $related = new Entry(); + $related = new Entry; $related->setDn('cn=foo,dc=local,dc=com'); - $unrelated = new Entry(); + $unrelated = new Entry; $unrelated->setDn('cn=bar,dc=local,dc=com'); $relation->setResults([$related]); @@ -167,18 +167,18 @@ public function test_contains() public function test_count() { - $relation = (new ModelRelationTestStub())->relation(); + $relation = (new ModelRelationTestStub)->relation(); - $relation->setResults([new Entry(), new Entry()]); + $relation->setResults([new Entry, new Entry]); $this->assertEquals(2, $relation->count()); } public function test_relation_default_model_uses_parent_connection() { - Container::addConnection(new Connection(), 'other'); + Container::addConnection(new Connection, 'other'); - $model = new ModelRelationTestStub(); + $model = new ModelRelationTestStub; $model->setConnection($connection = 'other'); @@ -189,9 +189,9 @@ public function test_relation_default_model_uses_parent_connection() public function test_relation_query_uses_models_parent_connection() { - Container::addConnection($connection = new Connection(), 'other'); + Container::addConnection($connection = new Connection, 'other'); - $model = new ModelRelationTestStub(); + $model = new ModelRelationTestStub; $model->setConnection($connectionName = 'other'); @@ -205,7 +205,7 @@ public function test_relation_query_uses_models_parent_connection() public function test_parent_model_scope_is_removed_from_relation_query() { - $relation = (new ModelRelationWithScopeTestStub())->relation(); + $relation = (new ModelRelationWithScopeTestStub)->relation(); $query = $relation->getRelationQuery(); @@ -221,7 +221,7 @@ public function test_has_many_foreign_values_are_properly_escaped_for_use_in_fil $escapedDnCharacters = ['\\', ',', '=', '+', '<', '>', ';', '"', '#']; $escapedFilterCharacters = ['\\', '*', '(', ')', "\x00"]; - $model = new ModelWithHasManyRelationTestStub(); + $model = new ModelWithHasManyRelationTestStub; $characters = implode('', array_merge($escapedDnCharacters, $escapedFilterCharacters)); @@ -237,9 +237,9 @@ public function test_has_many_foreign_values_are_properly_escaped_for_use_in_fil public function test_related_models_are_determined_with_out_of_order_object_classes() { - $relation = (new ModelRelationTestStub())->relation(); + $relation = (new ModelRelationTestStub)->relation(); - $related = new Entry(); + $related = new Entry; // Setting the object classes out of order with the related test stub. $related->objectclass = ['bar', 'foo']; @@ -252,9 +252,9 @@ public function test_related_models_are_determined_with_out_of_order_object_clas public function test_related_models_can_be_resolved_with_resolver_callback() { - $relation = (new ModelRelationTestStub())->relation(); + $relation = (new ModelRelationTestStub)->relation(); - $related = new Entry(); + $related = new Entry; $related->objectclass = ['bar', 'foo']; $related->setDn('cn=foo,dc=local,dc=com'); @@ -313,7 +313,7 @@ public static function boot(): void { parent::boot(); - static::addGlobalScope(new ModelRelationScopeTestStub()); + static::addGlobalScope(new ModelRelationScopeTestStub); } public function relation(): HasMany diff --git a/tests/Unit/Models/ModelRenameTest.php b/tests/Unit/Models/ModelRenameTest.php index f994a328..229d2410 100644 --- a/tests/Unit/Models/ModelRenameTest.php +++ b/tests/Unit/Models/ModelRenameTest.php @@ -108,7 +108,7 @@ public function test_rename_does_not_occur_when_given_the_same_rdn_and_parent_dn public function test_rename_without_existing_model() { - $model = new Entry(); + $model = new Entry; $this->expectException(ModelDoesNotExistException::class); @@ -117,7 +117,7 @@ public function test_rename_without_existing_model() public function test_rename_with_same_name_does_not_send_request() { - $model = new Entry(); + $model = new Entry; $model->setRawAttributes(['dn' => 'cn=John Doe,dc=acme,dc=org']); @@ -128,7 +128,7 @@ public function test_rename_with_same_name_does_not_send_request() public function test_rename_with_same_rdn_does_not_send_request() { - $model = new Entry(); + $model = new Entry; $model->setRawAttributes(['dn' => 'cn=John Doe,dc=acme,dc=org']); @@ -147,7 +147,7 @@ public function test_rename_escaping() ->andReturnTrue() ); - $model = new Entry(); + $model = new Entry; $model->setRawAttributes(['dn' => 'cn=John Doe,dc=acme,dc=org']); @@ -170,7 +170,7 @@ public function test_rename_escaping_parent() )->andReturnTrue() ); - $model = new Entry(); + $model = new Entry; $model->setRawAttributes([ 'dn' => 'cn=Джон Доу,ou=Тест\2C Группа\2C С\2C Запятые,dc=acme,dc=org', @@ -217,7 +217,7 @@ public function test_move() ->andReturnTrue() ); - $model = new Entry(); + $model = new Entry; $model->setRawAttributes(['dn' => 'cn=John Doe,dc=acme,dc=org']); diff --git a/tests/Unit/Models/ModelScopeTest.php b/tests/Unit/Models/ModelScopeTest.php index 0597a483..79a38220 100644 --- a/tests/Unit/Models/ModelScopeTest.php +++ b/tests/Unit/Models/ModelScopeTest.php @@ -24,7 +24,7 @@ protected function setUp(): void public function test_scopes_can_be_added_to_models() { - $model = new ModelWithGlobalScopeTestStub(); + $model = new ModelWithGlobalScopeTestStub; $this->assertInstanceOf(\Closure::class, $model->getGlobalScopes()['foo']); $this->assertInstanceOf(ScopeTestStub::class, $model->getGlobalScopes()[ScopeTestStub::class]); @@ -35,16 +35,16 @@ public function test_has_scope() $this->assertFalse(ModelWithGlobalScopeTestStub::hasGlobalScope('foo')); $this->assertFalse(ModelWithGlobalScopeTestStub::hasGlobalScope(ScopeTestStub::class)); - new ModelWithGlobalScopeTestStub(); + new ModelWithGlobalScopeTestStub; $this->assertTrue(ModelWithGlobalScopeTestStub::hasGlobalScope('foo')); $this->assertTrue(ModelWithGlobalScopeTestStub::hasGlobalScope(ScopeTestStub::class)); - $this->assertCount(2, (new ModelWithGlobalScopeTestStub())->getGlobalScopes()); + $this->assertCount(2, (new ModelWithGlobalScopeTestStub)->getGlobalScopes()); } public function test_scopes_are_applied_to_query() { - $query = (new ModelWithGlobalScopeTestStub())->newQuery()->applyScopes(); + $query = (new ModelWithGlobalScopeTestStub)->newQuery()->applyScopes(); $this->assertEquals([ 'field' => 'foo', @@ -55,7 +55,7 @@ public function test_scopes_are_applied_to_query() public function test_scopes_are_applied_to_pagination_request() { - $query = (new ModelWithGlobalScopeTestStub())->newQuery(); + $query = (new ModelWithGlobalScopeTestStub)->newQuery(); $this->assertEmpty($query->paginate()); $this->assertEquals([ @@ -67,7 +67,7 @@ public function test_scopes_are_applied_to_pagination_request() public function test_scopes_are_not_stacked_multiple_times() { - $query = (new ModelWithGlobalScopeTestStub())->newQuery(); + $query = (new ModelWithGlobalScopeTestStub)->newQuery(); $query->getQuery(); $query->getQuery(); @@ -151,9 +151,8 @@ protected static function boot(): void { parent::boot(); - static::addGlobalScope('foo', function () { - }); - static::addGlobalScope(new ScopeTestStub()); + static::addGlobalScope('foo', function () {}); + static::addGlobalScope(new ScopeTestStub); } public function newQueryBuilder(Connection $connection): Builder diff --git a/tests/Unit/Models/ModelSerializationTest.php b/tests/Unit/Models/ModelSerializationTest.php index 87b987eb..19d0f757 100644 --- a/tests/Unit/Models/ModelSerializationTest.php +++ b/tests/Unit/Models/ModelSerializationTest.php @@ -14,10 +14,10 @@ class ModelSerializationTest extends TestCase { public function testModelWithTimestampsCanBeSerializedAndEncoded() { - $whenchanged = (new Timestamp('windows'))->fromDateTime(new DateTime()); - $lastlogon = (new Timestamp('windows-int'))->fromDateTime(new DateTime()); + $whenchanged = (new Timestamp('windows'))->fromDateTime(new DateTime); + $lastlogon = (new Timestamp('windows-int'))->fromDateTime(new DateTime); - $model = (new User())->setRawAttributes([ + $model = (new User)->setRawAttributes([ 'cn' => 'René', 'whenchanged' => [(string) $whenchanged], 'lastlogon' => [(string) $lastlogon], diff --git a/tests/Unit/Models/ModelTest.php b/tests/Unit/Models/ModelTest.php index 46050381..b8daaaa8 100644 --- a/tests/Unit/Models/ModelTest.php +++ b/tests/Unit/Models/ModelTest.php @@ -29,7 +29,7 @@ protected function setUp(): void public function test_model_must_have_default_connection() { - $model = new Entry(); + $model = new Entry; $this->assertFalse($model->exists); $this->expectException(ContainerException::class); $model->getConnection(); @@ -37,7 +37,7 @@ public function test_model_must_have_default_connection() public function test_model_can_create_new_instances() { - $model = new Entry(); + $model = new Entry; $new = $model->newInstance(['foo' => 'bar']); $this->assertEquals($model->getConnectionName(), $new->getConnectionName()); $this->assertEquals(['foo' => ['bar']], $new->getAttributes()); @@ -46,7 +46,7 @@ public function test_model_can_create_new_instances() public function test_boot_is_called_upon_creation() { - new ModelBootingTestStub(); + new ModelBootingTestStub; $this->assertTrue(ModelBootingTestStub::isBooted()); $this->assertEquals([ModelBootingTestStub::class => true], ModelBootingTestStub::booted()); } @@ -74,7 +74,7 @@ public function test_getting_object_classes() public function test_getting_and_setting_dn() { - $model = new Entry(); + $model = new Entry; $model->setDn('foo'); $this->assertEquals('foo', $model->getDn()); $this->assertEquals('foo', (string) $model); @@ -82,7 +82,7 @@ public function test_getting_and_setting_dn() public function test_getting_parent_dn() { - $model = new Entry(); + $model = new Entry; $model->setDn('cn=user,dc=acme,dc=org'); $this->assertEquals('dc=acme,dc=org', $model->getParentDn($model->getDn())); $this->assertEquals('dc=acme,dc=org', $model->getParentDn()); @@ -127,7 +127,7 @@ public function test_getting_rdn() public function test_creatable_rdn() { - $model = new Entry(); + $model = new Entry; $this->assertEquals('cn=', $model->getCreatableRdn()); $model->cn = 'John Doe'; @@ -145,11 +145,11 @@ public function test_creatable_dn() 'base_dn' => 'dc=acme,dc=org', ])); - $model = new Entry(); + $model = new Entry; $model->cn = 'foo'; $this->assertEquals('cn=foo,dc=acme,dc=org', $model->getCreatableDn()); - $model = new Entry(); + $model = new Entry; $this->assertEquals('cn=,dc=acme,dc=org', $model->getCreatableDn()); $model = (new Entry)->inside('ou=Users,dc=acme,dc=org'); @@ -164,7 +164,7 @@ public function test_creatable_dn() public function test_raw_attribute_filling_sets_dn() { - $model = new Entry(); + $model = new Entry; $model->setRawAttributes(['dn' => 'bar']); $this->assertTrue($model->exists); @@ -177,14 +177,14 @@ public function test_raw_attribute_filling_sets_dn() public function test_raw_attribute_filling_sets_original() { - $model = new Entry(); + $model = new Entry; $model->setRawAttributes(['foo' => 'bar']); $this->assertEquals(['foo' => 'bar'], $model->getOriginal()); } public function test_raw_attribute_filling_removes_count_keys_recursively() { - $model = new Entry(); + $model = new Entry; $model->setRawAttributes([ 'count' => 1, @@ -210,7 +210,7 @@ public function test_raw_attribute_filling_removes_count_keys_recursively() public function test_attribute_manipulation() { - $model = new Entry(); + $model = new Entry; $model->cn = 'foo'; $this->assertEquals(['foo'], $model->cn); $this->assertTrue(isset($model->cn)); @@ -232,7 +232,7 @@ public function test_attribute_manipulation() public function test_has_attribute() { - $model = new Entry(); + $model = new Entry; $this->assertFalse($model->hasAttribute('foo')); $model->foo = null; @@ -256,7 +256,7 @@ public function test_has_attribute() public function test_setting_first_attribute() { - $model = new Entry(); + $model = new Entry; $model->foo = ['bar', 'baz']; $model->setFirstAttribute('foo', 'zal'); @@ -267,7 +267,7 @@ public function test_setting_first_attribute() public function test_adding_attribute_values() { - $model = new Entry(); + $model = new Entry; $model->foo = ['bar', 'baz']; $model->addAttributeValue('foo', 'zal'); @@ -283,7 +283,7 @@ public function test_adding_attribute_values() public function test_removing_attribute_values() { - $model = new Entry(); + $model = new Entry; $model->foo = ['bar', 'baz', 'zal']; $model->removeAttributeValue('missing', 'foo'); @@ -303,7 +303,7 @@ public function test_removing_attribute_values() public function test_attribute_keys_are_normalized() { - $model = new Entry(); + $model = new Entry; $model->FOO = 1; $model->BARbAz = 2; $model->foo_bar = 3; @@ -371,7 +371,7 @@ public function test_changed_attributes() public function test_reset_integer_is_kept_in_tact_when_batch_modifications_are_generated() { - $model = new Entry(); + $model = new Entry; $model->setRawAttributes(['pwdlastset' => 'value']); @@ -500,7 +500,7 @@ public function test_hydrate() ], ]; - $model = new Entry(); + $model = new Entry; $model->setConnection('other'); $collection = $model->hydrate($records); @@ -516,39 +516,39 @@ public function test_hydrate() public function test_add_modification() { - $model = new Entry(); + $model = new Entry; $model->addModification(['attrib' => 'foo', 'values' => ['bar'], 'modtype' => 3]); $this->assertEquals([['attrib' => 'foo', 'values' => ['bar'], 'modtype' => 3]], $model->getModifications()); - $model = new Entry(); + $model = new Entry; $model->addModification(new BatchModification('foo', 3, ['bar'])); $this->assertEquals([['attrib' => 'foo', 'values' => ['bar'], 'modtype' => 3]], $model->getModifications()); } public function test_add_modification_without_attrib() { - $model = new Entry(); + $model = new Entry; $this->expectException(\InvalidArgumentException::class); $model->addModification(['values' => ['Changed'], 'modtype' => 3]); } public function test_add_modification_without_modtype() { - $model = new Entry(); + $model = new Entry; $this->expectException(\InvalidArgumentException::class); $model->addModification(['attrib' => 'foo', 'values' => ['bar']]); } public function test_add_modification_without_values() { - $model = new Entry(); + $model = new Entry; $model->addModification(['attrib' => 'foo', 'modtype' => 3]); $this->assertEquals([['attrib' => 'foo', 'modtype' => 3]], $model->getModifications()); } public function test_set_modifications() { - $model = new Entry(); + $model = new Entry; $model->setModifications([ ['attrib' => 'foo', 'modtype' => 3, 'values' => ['bar']], new BatchModification('bar', 3, ['baz']), @@ -562,7 +562,7 @@ public function test_set_modifications() public function test_modifications_are_created_from_dirty() { - $model = new Entry(); + $model = new Entry; $model->setRawAttributes([ 'cn' => ['Common Name'], 'samaccountname' => ['Account Name'], @@ -593,7 +593,7 @@ public function test_modifications_are_created_from_dirty() public function test_modifications_that_contain_identical_values_are_not_used() { - $model = new Entry(); + $model = new Entry; $model->setRawAttributes(['useraccountcontrol' => 512]); $model->useraccountcontrol = '512'; @@ -648,7 +648,7 @@ public function test_is_not() public function test_is_descendent_of() { - $model = new Entry(); + $model = new Entry; $this->assertFalse($model->isDescendantOf()); $this->assertFalse($model->isDescendantOf('')); @@ -659,7 +659,7 @@ public function test_is_descendent_of() $this->assertTrue($model->isDescendantOf('ou=bar,dc=acme,dc=org')); $this->assertTrue($model->isDescendantOf('ou=bar,dc=ACME,dc=org')); - $parent = new Entry(); + $parent = new Entry; $parent->setDn('ou=bar,dc=acme,dc=org'); $this->assertTrue($model->isDescendantOf($parent)); @@ -669,7 +669,7 @@ public function test_is_descendent_of() public function test_is_ancestor_of() { - $model = new Entry(); + $model = new Entry; $this->assertFalse($model->isAncestorOf()); $this->assertFalse($model->isAncestorOf('')); @@ -677,7 +677,7 @@ public function test_is_ancestor_of() $this->assertTrue($model->isAncestorOf('cn=foo,ou=bar,dc=acme,dc=org')); $this->assertTrue($model->isAncestorOf('cn=foo,ou=test,ou=bar,dc=acme,dc=org')); - $child = new Entry(); + $child = new Entry; $child->setDn('cn=foo,ou=bar,dc=acme,dc=org'); $this->assertTrue($model->isAncestorOf($child)); @@ -687,7 +687,7 @@ public function test_is_ancestor_of() public function test_is_child_of() { - $model = new Entry(); + $model = new Entry; $this->assertFalse($model->isChildOf()); $model->setDn('dc=bar,dc=baz'); @@ -702,7 +702,7 @@ public function test_is_child_of() public function test_is_parent_of() { - $model = new Entry(); + $model = new Entry; $this->assertFalse($model->isParentOf()); $model->setDn('dc=bar,dc=baz'); @@ -720,14 +720,14 @@ public function test_dn_comparison_methods_can_use_base_dn_substitution() 'base_dn' => 'dc=local,dc=com', ])); - $ou = new Entry(); + $ou = new Entry; $ou->setDn('ou=users,dc=local,dc=com'); $this->assertTrue($ou->isDescendantOf('{base}')); $this->assertTrue($ou->isSiblingOf('ou=admins,{base}')); $this->assertTrue($ou->isParentOf('cn=foo,ou=users,{base}')); $this->assertTrue($ou->isAncestorOf('cn=foo,ou=users,{base}')); - $child = new Entry(); + $child = new Entry; $child->setDn('cn=foo,ou=users,dc=local,dc=com'); $this->assertTrue($child->isDescendantOf('{base}')); $this->assertTrue($child->isChildOf('ou=users,{base}')); @@ -746,7 +746,7 @@ public function test_generated_dns_are_properly_escaped() { Container::addConnection(new Connection); - $model = new Entry(); + $model = new Entry; $model->inside('dc=local,dc=com'); @@ -771,7 +771,7 @@ public function test_generated_dns_properly_substitute_base_on_creation() ->andReturnTrue() ); - $model = new Entry(); + $model = new Entry; $model->inside('{base}'); @@ -788,12 +788,12 @@ public function test_setting_dn_attributes_set_distinguished_name_on_model() $this->assertEquals('foo', (new Entry(['distinguishedname' => 'foo']))->getDn()); $this->assertEquals('foo', Entry::make(['distinguishedname' => 'foo'])->getDn()); - $model = new Entry(); + $model = new Entry; $model->dn = 'foo'; $this->assertEquals('foo', $model->getDn()); $this->assertEquals(['foo'], $model->getAttributes()['dn']); - $model = new Entry(); + $model = new Entry; $model->distinguishedname = 'foo'; $this->assertEquals('foo', $model->getDn()); $this->assertEquals(['foo'], $model->getAttributes()['distinguishedname']); @@ -842,9 +842,7 @@ public function test_morph_into_with_custom_resolver_callback() class ModelCreateTestStub extends Model { - public function save(array $attributes = []): void - { - } + public function save(array $attributes = []): void {} } class ModelWithDatesStub extends Model diff --git a/tests/Unit/Models/OpenLDAP/ModelTest.php b/tests/Unit/Models/OpenLDAP/ModelTest.php index c33be68e..c9d62072 100644 --- a/tests/Unit/Models/OpenLDAP/ModelTest.php +++ b/tests/Unit/Models/OpenLDAP/ModelTest.php @@ -21,7 +21,7 @@ public function test_entry_uuid_is_always_added_to_select_list_with_asterisk_whe { Container::addConnection(new Connection); - $model = new Entry(); + $model = new Entry; $query = $model->newQuery(); @@ -35,7 +35,7 @@ public function test_entry_uuid_is_added_to_a_select_list_without_asterisk_when_ { Container::addConnection(new Connection); - $model = new Entry(); + $model = new Entry; $query = $model->newQuery()->select(['foo']); diff --git a/tests/Unit/Models/OpenLDAP/UserTest.php b/tests/Unit/Models/OpenLDAP/UserTest.php index ceac4b30..e03a4d11 100644 --- a/tests/Unit/Models/OpenLDAP/UserTest.php +++ b/tests/Unit/Models/OpenLDAP/UserTest.php @@ -26,7 +26,7 @@ protected function tearDown(): void public function test_settings_users_password_uses_ssha_algo() { - $user = new OpenLDAPUserTestStub(); + $user = new OpenLDAPUserTestStub; $user->password = 'secret'; @@ -37,7 +37,7 @@ public function test_settings_users_password_uses_ssha_algo() public function test_algo_is_automatically_detected_when_changing_a_users_password() { - $user = (new OpenLDAPUserTestStub())->setRawAttributes([ + $user = (new OpenLDAPUserTestStub)->setRawAttributes([ 'userpassword' => [ '{MD5}Xr4ilOzQ4PCOq3aQ0qbuaQ==', ], @@ -55,7 +55,7 @@ public function test_algo_is_automatically_detected_when_changing_a_users_passwo public function test_algo_and_salt_is_automatically_detected_when_changing_a_users_password() { - $user = (new OpenLDAPUserTestStub())->setRawAttributes([ + $user = (new OpenLDAPUserTestStub)->setRawAttributes([ 'userpassword' => [ Password::sha512crypt('secret'), ], @@ -87,7 +87,5 @@ public function test_correct_auth_identifier_is_returned() class OpenLDAPUserTestStub extends User { - protected function assertSecureConnection(): void - { - } + protected function assertSecureConnection(): void {} } diff --git a/tests/Unit/Models/Relations/HasManyTest.php b/tests/Unit/Models/Relations/HasManyTest.php index 3bac7401..6a911c37 100644 --- a/tests/Unit/Models/Relations/HasManyTest.php +++ b/tests/Unit/Models/Relations/HasManyTest.php @@ -65,7 +65,7 @@ public function test_detach_or_delete_parent_with_no_results_does_not_delete_par $model->shouldReceive('delete')->never(); $relation = m::mock(HasMany::class)->makePartial(); - $relation->shouldReceive('get')->with('dn')->andReturn(new Collection()); + $relation->shouldReceive('get')->with('dn')->andReturn(new Collection); $relation->detachOrDeleteParent($model); } diff --git a/tests/Unit/Query/ArrayCacheStoreTest.php b/tests/Unit/Query/ArrayCacheStoreTest.php index ab380d09..73ca8a73 100644 --- a/tests/Unit/Query/ArrayCacheStoreTest.php +++ b/tests/Unit/Query/ArrayCacheStoreTest.php @@ -10,16 +10,16 @@ class ArrayCacheStoreTest extends TestCase { public function test_get_returns_default_value() { - $this->assertNull((new ArrayCacheStore())->get('invalid')); + $this->assertNull((new ArrayCacheStore)->get('invalid')); - $value = (new ArrayCacheStore())->get('invalid', 'value'); + $value = (new ArrayCacheStore)->get('invalid', 'value'); $this->assertEquals('value', $value); } public function test_set_stores_value() { - $store = new ArrayCacheStore(); + $store = new ArrayCacheStore; $this->assertTrue($store->set('key', 'value')); @@ -28,7 +28,7 @@ public function test_set_stores_value() public function test_set_stores_values_without_ttl_indefinitely() { - $store = new ArrayCacheStore(); + $store = new ArrayCacheStore; $store->set('key', 'value'); @@ -41,7 +41,7 @@ public function test_set_keys_with_expiry_return_default_value_when_expired() { Carbon::setTestNow(Carbon::now()); - $store = new ArrayCacheStore(); + $store = new ArrayCacheStore; $store->set('key', 'value', 10); $this->assertEquals('value', $store->get('key', 'foo')); @@ -54,7 +54,7 @@ public function test_set_keys_with_expiry_return_default_value_when_expired() public function test_set_multiple__stores_values() { - $store = new ArrayCacheStore(); + $store = new ArrayCacheStore; $this->assertTrue( $store->setMultiple([ @@ -69,7 +69,7 @@ public function test_set_multiple__stores_values() public function test_get_multiple_returns_stored_values() { - $store = new ArrayCacheStore(); + $store = new ArrayCacheStore; $store->set('foo', 'bar'); $store->set('baz', 'zar'); @@ -87,7 +87,7 @@ public function test_get_multiple_returns_stored_values() public function test_delete_removes_item_from_storage() { - $store = new ArrayCacheStore(); + $store = new ArrayCacheStore; $store->set('key', 'value'); @@ -99,7 +99,7 @@ public function test_delete_removes_item_from_storage() public function test_delete_multiple_removes_items_from_storage() { - $store = new ArrayCacheStore(); + $store = new ArrayCacheStore; $store->set('foo', 'bar'); $store->set('baz', 'zal'); @@ -114,7 +114,7 @@ public function test_delete_multiple_removes_items_from_storage() public function test_clear_removes_all_items_from_storage() { - $store = new ArrayCacheStore(); + $store = new ArrayCacheStore; $store->setMultiple(['foo' => 'bar', 'baz' => 'zal']); @@ -131,7 +131,7 @@ public function test_clear_removes_all_items_from_storage() public function test_has_detects_items_in_storage() { - $store = new ArrayCacheStore(); + $store = new ArrayCacheStore; $store->setMultiple(['foo' => 'bar', 'baz' => 'zal']); diff --git a/tests/Unit/Query/BuilderCacheTest.php b/tests/Unit/Query/BuilderCacheTest.php index 5e702af6..5dd26a84 100644 --- a/tests/Unit/Query/BuilderCacheTest.php +++ b/tests/Unit/Query/BuilderCacheTest.php @@ -17,9 +17,9 @@ class BuilderCacheTest extends TestCase { public function test_cache_is_set_from_connection_onto_new_query_builders() { - $conn = new Connection(); + $conn = new Connection; - $conn->setCache(new ArrayCacheStore()); + $conn->setCache(new ArrayCacheStore); $query = $conn->query(); @@ -29,9 +29,9 @@ public function test_cache_is_set_from_connection_onto_new_query_builders() public function test_cache_is_set_onto_new_model_query_builders() { - $conn = new Connection(); + $conn = new Connection; - $conn->setCache(new ArrayCacheStore()); + $conn->setCache(new ArrayCacheStore); $container = Container::getInstance(); $container->setDefaultConnection('default'); @@ -46,7 +46,7 @@ public function test_cache_is_set_onto_new_model_query_builders() public function test_cache_key_generation_connects_to_server_when_not_connected() { $ldap = (new LdapFake)->expect( - LdapFake::operation('bind')->andReturn(new LdapResultResponse()) + LdapFake::operation('bind')->andReturn(new LdapResultResponse) ); $ldap->setHost($host = 'localhost'); diff --git a/tests/Unit/Query/BuilderTest.php b/tests/Unit/Query/BuilderTest.php index 998422c5..870353c4 100644 --- a/tests/Unit/Query/BuilderTest.php +++ b/tests/Unit/Query/BuilderTest.php @@ -1231,7 +1231,7 @@ public function test_find() ->shouldAllowAnyBind() ->expect([ LdapFake::operation('setOption')->with(LDAP_OPT_SERVER_CONTROLS, [])->once()->andReturnTrue(), - LdapFake::operation('parseResult')->once()->andReturn(new LdapResultResponse()), + LdapFake::operation('parseResult')->once()->andReturn(new LdapResultResponse), LdapFake::operation('read')->once()->with($dn, '(objectclass=*)', ['*'])->andReturn($results), ]); @@ -1432,7 +1432,7 @@ function ($controls) { && $controls[LDAP_CONTROL_SORTREQUEST]['value'] === [['attr' => 'cn', 'reverse' => false]] && $controls[LDAP_CONTROL_VLVREQUEST]['value'] === ['before' => 0, 'after' => 99, 'offset' => 1, 'count' => 0]; }, - ])->andReturn(new LdapResultResponse()); + ])->andReturn(new LdapResultResponse); }, ]); @@ -1478,7 +1478,7 @@ function ($controls) { && $controls[LDAP_CONTROL_SORTREQUEST]['value'] === [['attr' => 'cn', 'reverse' => false]] && $controls[LDAP_CONTROL_VLVREQUEST]['value'] === ['before' => 0, 'after' => 99, 'offset' => 1, 'count' => 0]; }, - ])->andReturn(new LdapResultResponse()); + ])->andReturn(new LdapResultResponse); }, ]); diff --git a/tests/Unit/Query/CacheTest.php b/tests/Unit/Query/CacheTest.php index 19d34606..b495b769 100644 --- a/tests/Unit/Query/CacheTest.php +++ b/tests/Unit/Query/CacheTest.php @@ -11,21 +11,21 @@ class CacheTest extends TestCase { public function test_cache_can_be_given_array_store() { - $cache = new Cache(new ArrayCacheStore()); + $cache = new Cache(new ArrayCacheStore); $this->assertInstanceOf(ArrayCacheStore::class, $cache->store()); } public function test_get_returns_null_by_default() { - $cache = new Cache(new ArrayCacheStore()); + $cache = new Cache(new ArrayCacheStore); $this->assertNull($cache->get('invalid')); } public function test_items_can_be_put() { - $cache = new Cache(new ArrayCacheStore()); + $cache = new Cache(new ArrayCacheStore); $this->assertTrue($cache->put('foo', 'bar')); $this->assertEquals('bar', $cache->get('foo')); @@ -39,7 +39,7 @@ public function test_items_can_be_put() public function test_items_can_be_deleted() { - $cache = new Cache(new ArrayCacheStore()); + $cache = new Cache(new ArrayCacheStore); $cache->put('test', 'test'); @@ -52,7 +52,7 @@ public function test_items_can_be_deleted() public function test_remember_executes_closure_and_stores_value() { - $cache = new Cache(new ArrayCacheStore()); + $cache = new Cache(new ArrayCacheStore); $cache->remember('foo', Carbon::now()->addMinute(), function () { return 'bar'; diff --git a/tests/Unit/Query/GrammarTest.php b/tests/Unit/Query/GrammarTest.php index d2043e92..c82a59ff 100644 --- a/tests/Unit/Query/GrammarTest.php +++ b/tests/Unit/Query/GrammarTest.php @@ -9,7 +9,7 @@ class GrammarTest extends TestCase { public function test_wrap() { - $g = new Grammar(); + $g = new Grammar; $wrapped = $g->wrap('test'); @@ -20,7 +20,7 @@ public function test_wrap() public function test_wrap_prefix() { - $g = new Grammar(); + $g = new Grammar; $wrapped = $g->wrap('test', '(!'); @@ -31,7 +31,7 @@ public function test_wrap_prefix() public function test_wrap_suffix() { - $g = new Grammar(); + $g = new Grammar; $wrapped = $g->wrap('test', null, '=)'); @@ -42,7 +42,7 @@ public function test_wrap_suffix() public function test_wrap_both() { - $g = new Grammar(); + $g = new Grammar; $wrapped = $g->wrap('test', '(!prefix', 'suffix)'); @@ -59,6 +59,6 @@ public function test_all_operators() 'ends_with', 'not_ends_with', 'contains', 'not_contains', ]; - $this->assertEquals($expected, (new Grammar())->getOperators()); + $this->assertEquals($expected, (new Grammar)->getOperators()); } } diff --git a/tests/Unit/Query/Model/ActiveDirectoryTest.php b/tests/Unit/Query/Model/ActiveDirectoryTest.php index 1aa273ab..9e7adaa2 100644 --- a/tests/Unit/Query/Model/ActiveDirectoryTest.php +++ b/tests/Unit/Query/Model/ActiveDirectoryTest.php @@ -12,7 +12,7 @@ class ActiveDirectoryTest extends TestCase { protected function newBuilder(): ActiveDirectoryBuilder { - return (new ActiveDirectoryBuilder(new Connection([], new LdapFake())))->setModel(new Entry); + return (new ActiveDirectoryBuilder(new Connection([], new LdapFake)))->setModel(new Entry); } public function test_where_member_of() diff --git a/tests/Unit/Query/Model/BuilderScopeTest.php b/tests/Unit/Query/Model/BuilderScopeTest.php index 8e540233..42293d1e 100644 --- a/tests/Unit/Query/Model/BuilderScopeTest.php +++ b/tests/Unit/Query/Model/BuilderScopeTest.php @@ -15,7 +15,7 @@ class BuilderScopeTest extends TestCase { public function test_closure_scopes_can_be_applied() { - $b = new Builder(new Connection()); + $b = new Builder(new Connection); $b->withGlobalScope('foo', function ($query) use ($b) { $this->assertSame($b, $query); @@ -26,11 +26,11 @@ public function test_closure_scopes_can_be_applied() public function test_class_scopes_can_be_applied() { - $b = new Builder(new Connection()); + $b = new Builder(new Connection); $b->setModel(new Entry); - $b->withGlobalScope('foo', new TestModelScope()); + $b->withGlobalScope('foo', new TestModelScope); $this->assertEquals('(foo=LdapRecord\Models\Entry)', $b->getUnescapedQuery()); @@ -40,10 +40,9 @@ public function test_class_scopes_can_be_applied() public function test_scopes_can_be_removed_after_being_added() { - $b = new Builder(new Connection()); + $b = new Builder(new Connection); - $b->withGlobalScope('foo', function () { - }); + $b->withGlobalScope('foo', function () {}); $b->withoutGlobalScope('foo'); @@ -52,12 +51,10 @@ public function test_scopes_can_be_removed_after_being_added() public function test_many_scopes_can_be_removed_after_being_applied() { - $b = new Builder(new Connection()); + $b = new Builder(new Connection); - $b->withGlobalScope('foo', function () { - }); - $b->withGlobalScope('bar', function () { - }); + $b->withGlobalScope('foo', function () {}); + $b->withGlobalScope('bar', function () {}); $b->withoutGlobalScopes(['foo', 'bar']); diff --git a/tests/Unit/Testing/AuthGuardFakeTest.php b/tests/Unit/Testing/AuthGuardFakeTest.php index dcb80ac1..fd6f62ce 100644 --- a/tests/Unit/Testing/AuthGuardFakeTest.php +++ b/tests/Unit/Testing/AuthGuardFakeTest.php @@ -11,7 +11,7 @@ class AuthGuardFakeTest extends TestCase { public function testBindAsConfiguredUserAlwaysReturnsNull() { - $guard = new AuthGuardFake(new LdapFake(), new DomainConfiguration()); + $guard = new AuthGuardFake(new LdapFake, new DomainConfiguration); $this->assertNull($guard->bindAsConfiguredUser()); } diff --git a/tests/Unit/Testing/ConnectionFakeTest.php b/tests/Unit/Testing/ConnectionFakeTest.php index ddd4f0ed..a1eb401f 100644 --- a/tests/Unit/Testing/ConnectionFakeTest.php +++ b/tests/Unit/Testing/ConnectionFakeTest.php @@ -63,6 +63,4 @@ public function testActingAsWithDn() } } -class ExtendedLdapFake extends LdapFake -{ -} +class ExtendedLdapFake extends LdapFake {} diff --git a/tests/Unit/Testing/LdapExpectationTest.php b/tests/Unit/Testing/LdapExpectationTest.php index 67c59339..22de8c6d 100644 --- a/tests/Unit/Testing/LdapExpectationTest.php +++ b/tests/Unit/Testing/LdapExpectationTest.php @@ -73,7 +73,7 @@ public function test_exception_can_be_applied_with_plain_exception() { $expectation = (new LdapExpectation('method')); - $expectation->andThrow(new Exception()); + $expectation->andThrow(new Exception); $this->assertInstanceOf(Exception::class, $expectation->getExpectedException()); } @@ -82,7 +82,7 @@ public function test_exception_can_be_applied_with_other_exception() { $expectation = (new LdapExpectation('method')); - $expectation->andThrow(new LdapRecordException()); + $expectation->andThrow(new LdapRecordException); $this->assertInstanceOf(LdapRecordException::class, $expectation->getExpectedException()); } diff --git a/tests/Unit/Testing/LdapFakeTest.php b/tests/Unit/Testing/LdapFakeTest.php index b649ca5b..f5b8fef1 100644 --- a/tests/Unit/Testing/LdapFakeTest.php +++ b/tests/Unit/Testing/LdapFakeTest.php @@ -15,7 +15,7 @@ class LdapFakeTest extends TestCase { public function test_operation() { - $fake = new LdapFake(); + $fake = new LdapFake; $operation = $fake->operation('foo'); @@ -25,7 +25,7 @@ public function test_operation() public function test_should_allow_bind_with() { - $fake = new LdapFake(); + $fake = new LdapFake; $fake->shouldAllowBindWith('foo'); @@ -40,7 +40,7 @@ public function test_should_allow_bind_with() public function test_expect() { - $fake = new LdapFake(); + $fake = new LdapFake; $fake->expect(['foo' => 'bar']); $fake->expect($fake->operation('bar')); @@ -53,7 +53,7 @@ public function test_expect() public function test_remove_expectation() { - $fake = new LdapFake(); + $fake = new LdapFake; $fake->expect([ 'foo' => 'bar', @@ -73,7 +73,7 @@ public function test_remove_expectation() public function test_should_return_error_number() { - $fake = new LdapFake(); + $fake = new LdapFake; $fake->shouldReturnErrorNumber(10); @@ -82,7 +82,7 @@ public function test_should_return_error_number() public function test_should_return_error() { - $fake = new LdapFake(); + $fake = new LdapFake; $fake->shouldReturnError('foo'); @@ -91,7 +91,7 @@ public function test_should_return_error() public function test_should_return_diagnostic_message() { - $fake = new LdapFake(); + $fake = new LdapFake; $fake->shouldReturnDiagnosticMessage('foo'); @@ -100,11 +100,11 @@ public function test_should_return_diagnostic_message() public function test_connect() { - $fake = new LdapFake(); + $fake = new LdapFake; $this->assertTrue($fake->connect('host', 389)); - $fake = new LdapFake(); + $fake = new LdapFake; $fake->expect(['connect' => false]); @@ -113,7 +113,7 @@ public function test_connect() public function test_bind_without_expectation_throws_exception() { - $fake = new LdapFake(); + $fake = new LdapFake; $this->expectException(Exception::class); $this->expectExceptionMessage('LDAP method [bind] was unexpected.'); @@ -123,9 +123,9 @@ public function test_bind_without_expectation_throws_exception() public function test_bind_with_expectation_returns_result() { - $fake = new LdapFake(); + $fake = new LdapFake; - $fake->expect(['bind' => $response = new LdapResultResponse()]); + $fake->expect(['bind' => $response = new LdapResultResponse]); $this->assertSame($response, $fake->bind('foo', 'bar')); @@ -134,7 +134,7 @@ public function test_bind_with_expectation_returns_result() public function test_bind_with_expectation_returns_failed_result() { - $fake = new LdapFake(); + $fake = new LdapFake; $fake->expect(['bind' => $response = new LdapResultResponse(1)]); @@ -145,11 +145,11 @@ public function test_bind_with_expectation_returns_failed_result() public function test_close() { - $fake = new LdapFake(); + $fake = new LdapFake; $this->assertTrue($fake->close()); - $fake = new LdapFake(); + $fake = new LdapFake; $fake->expect(['close' => false]); @@ -158,12 +158,12 @@ public function test_close() public function test_get_entries() { - $this->assertEquals(['foo', 'bar'], (new LdapFake())->getEntries(['foo', 'bar'])); + $this->assertEquals(['foo', 'bar'], (new LdapFake)->getEntries(['foo', 'bar'])); } public function test_assert_minimum_expectation_counts_does_not_throw_exception_on_indefinite_expectations() { - $fake = (new LdapFake())->expect( + $fake = (new LdapFake)->expect( $expectation = LdapFake::operation('foo') ); @@ -174,7 +174,7 @@ public function test_assert_minimum_expectation_counts_does_not_throw_exception_ public function test_assert_minimum_expectation_counts_throws_exception_on_expected_count_not_met() { - $fake = (new LdapFake())->expect( + $fake = (new LdapFake)->expect( $expectation = LdapFake::operation('foo')->once() );