Skip to content

Commit

Permalink
Apply code style to tests files
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Dec 10, 2024
1 parent e6abe0b commit 9335a89
Show file tree
Hide file tree
Showing 272 changed files with 7,840 additions and 8,195 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

return \Spiral\CodeStyle\Builder::create()
->include(__DIR__ . '/src')
->include(__DIR__ . '/tests')
->include(__FILE__)
->cache('./runtime/php-cs-fixer.cache')
->allowRisky()
Expand Down
3 changes: 0 additions & 3 deletions tests/ORM/Fixtures/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
class Comment
{
public $id;

public $message;

/** @var User */
Expand All @@ -21,9 +20,7 @@ class Comment
public $favoredBy;

public $parent;

public $level;

public UserWithUUIDPrimaryKey $userWithUuid;

public function __construct()
Expand Down
3 changes: 0 additions & 3 deletions tests/ORM/Fixtures/CompositePK.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ class CompositePK
public $key2;
public $key3;
public $key4;

public $child_entity;

public $child_key1;
public $child_key2;
public $child_key3;
public $child_key4;

public $children;
public $pivoted;

Expand Down
2 changes: 0 additions & 2 deletions tests/ORM/Fixtures/CompositePKChild.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ class CompositePKChild
public $key2;
public $key3;
public $key4;

public $parent_key1;
public $parent_key2;
public $parent_key3;
public $parent_key4;

public $parent;
public $nested;
public $pivoted;
Expand Down
2 changes: 0 additions & 2 deletions tests/ORM/Fixtures/CompositePKNested.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ class CompositePKNested
public $key2;
public $key3;
public $key4;

public $parent_key1;
public $parent_key2;
public $parent_key3;
public $parent_key4;

public $parent;
}
3 changes: 0 additions & 3 deletions tests/ORM/Fixtures/CompositePKPivot.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@ class CompositePKPivot
public $key2;
public $key3;
public $key4;

public $parent_key1;
public $parent_key2;
public $parent_key3;
public $parent_key4;

public $child_key1;
public $child_key2;
public $child_key3;
public $child_key4;

public $as;
}
4 changes: 1 addition & 3 deletions tests/ORM/Fixtures/CustomCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@

use Doctrine\Common\Collections\ArrayCollection;

final class CustomCollection extends ArrayCollection
{
}
final class CustomCollection extends ArrayCollection {}
1 change: 0 additions & 1 deletion tests/ORM/Fixtures/CyclicRef/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class Comment
{
public $id;
public $post_id;

public $message;

/** @var User */
Expand Down
5 changes: 2 additions & 3 deletions tests/ORM/Fixtures/CyclicRef/TimestampedMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Cycle\ORM\Heap\Node;
use Cycle\ORM\Heap\State;
use Cycle\ORM\Mapper\Mapper;
use DateTimeImmutable;

class TimestampedMapper extends Mapper
{
Expand All @@ -20,7 +19,7 @@ public function queueCreate($entity, Node $node, State $state): CommandInterface
/** @var Insert $cmd */
$cmd = parent::queueCreate($entity, $node, $state);

$dt = new DateTimeImmutable();
$dt = new \DateTimeImmutable();
$state->register('created_at', $dt);
$state->register('updated_at', $dt);

Expand All @@ -32,7 +31,7 @@ public function queueUpdate($entity, Node $node, State $state): CommandInterface
/** @var Update $cmd */
$cmd = parent::queueUpdate($entity, $node, $state);

$cmd->registerAppendix('updated_at', new DateTimeImmutable());
$cmd->registerAppendix('updated_at', new \DateTimeImmutable());

return $cmd;
}
Expand Down
1 change: 0 additions & 1 deletion tests/ORM/Fixtures/CyclicRef/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class User
{
public $id;
public $email;

public $created_at;
public $updated_at;
}
4 changes: 0 additions & 4 deletions tests/ORM/Fixtures/CyclicRef2/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ class Document
{
public $tenant_id;
public $id;

public $tenant;

public $preference_id;
public $preference;

public $body;

public $created_at;
public $updated_at;
}
2 changes: 0 additions & 2 deletions tests/ORM/Fixtures/CyclicRef2/Preference.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ class Preference
public $tenant;
public $tenant_id;
public $id;

public $flag;
public $option;

public $created_at;
public $updated_at;
}
12 changes: 0 additions & 12 deletions tests/ORM/Fixtures/DifferentSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,21 @@

class DifferentSource implements SourceInterface
{
/**
* @inheritDoc
*/
public function getDatabase(): DatabaseInterface
{
throw new \RuntimeException('Not implemented.');
}

/**
* @inheritDoc
*/
public function getTable(): string
{
throw new \RuntimeException('Not implemented.');
}

/**
* @inheritDoc
*/
public function withScope(?ScopeInterface $scope): SourceInterface
{
return $this;
}

/**
* @inheritDoc
*/
public function getScope(): ?ScopeInterface
{
return null;
Expand Down
2 changes: 1 addition & 1 deletion tests/ORM/Fixtures/Enum/TypeIntEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ enum TypeIntEnum: int

public static function make(int|string $value): ?self
{
return self::tryFrom((int)$value);
return self::tryFrom((int) $value);
}
}
2 changes: 1 addition & 1 deletion tests/ORM/Fixtures/Enum/TypeStringEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ enum TypeStringEnum: string

public static function make(int|string $value): ?self
{
return self::tryFrom((string)$value);
return self::tryFrom((string) $value);
}
}
4 changes: 1 addition & 3 deletions tests/ORM/Fixtures/Favorite.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@

namespace Cycle\ORM\Tests\Fixtures;

class Favorite
{
}
class Favorite {}
1 change: 0 additions & 1 deletion tests/ORM/Fixtures/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
class Group
{
public $id;

public $name;

/**
Expand Down
1 change: 0 additions & 1 deletion tests/ORM/Fixtures/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ class Image
{
public $id;
public $parent;

public $url;
}
4 changes: 1 addition & 3 deletions tests/ORM/Fixtures/ImagedInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@

namespace Cycle\ORM\Tests\Fixtures;

interface ImagedInterface
{
}
interface ImagedInterface {}
8 changes: 4 additions & 4 deletions tests/ORM/Fixtures/OptimisticLockMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function lock(Node $node, State $state, Update|Delete $command): Wrapp
{
$scopeValue = $node->getData()[$this->lockField] ?? null;
if ($scopeValue === null) {
throw new \RuntimeException(sprintf('The `%s` field is not set.', $this->lockField));
throw new \RuntimeException(\sprintf('The `%s` field is not set.', $this->lockField));
}

if ($command instanceof Update && $state->getData()[$this->lockField] === $scopeValue) {
Expand All @@ -50,16 +50,16 @@ protected function lock(Node $node, State $state, Update|Delete $command): Wrapp
return WrappedCommand::wrapCommand($command)
->withAfterExecution(static function (ScopeCarrierInterface $command) use ($node): void {
if ($command->getAffectedRows() === 0) {
throw new \RuntimeException(sprintf(
throw new \RuntimeException(\sprintf(
'The `%s` record is locked.',
$node->getRole()
$node->getRole(),
));
}
});
}

private function getLockingValue(Node $node): string
{
return microtime();
return \microtime();
}
}
1 change: 0 additions & 1 deletion tests/ORM/Fixtures/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ class Post implements ImagedInterface
public $comments;

public ?Post $parent = null;

public UserWithUUIDPrimaryKey $userWithUuidPK;
}
2 changes: 0 additions & 2 deletions tests/ORM/Fixtures/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
class Tag
{
public $id;

public $name;

public $users;

public function __construct()
Expand Down
4 changes: 1 addition & 3 deletions tests/ORM/Fixtures/TestInsertCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@

use Cycle\Database\Query\InsertQuery;

class TestInsertCommand extends InsertQuery
{
}
class TestInsertCommand extends InsertQuery {}
4 changes: 1 addition & 3 deletions tests/ORM/Fixtures/TestInsertCommandWithReturning.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@

use Cycle\Database\Query\InsertQuery;

abstract class TestInsertCommandWithReturning extends InsertQuery implements \Cycle\Database\Query\ReturningInterface
{
}
abstract class TestInsertCommandWithReturning extends InsertQuery implements \Cycle\Database\Query\ReturningInterface {}
29 changes: 14 additions & 15 deletions tests/ORM/Fixtures/TestLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class TestLogger implements LoggerInterface
use LoggerTrait;

private $display;

private $countWrites;
private $countReads;

Expand All @@ -37,11 +36,11 @@ public function countReadQueries(): int
public function log($level, $message, array $context = []): void
{
if (!empty($context['elapsed'])) {
$sql = strtolower($message);
$sql = \strtolower($message);
if (
strpos($sql, 'insert') === 0 ||
strpos($sql, 'update') === 0 ||
strpos($sql, 'delete') === 0
\strpos($sql, 'insert') === 0 ||
\strpos($sql, 'update') === 0 ||
\strpos($sql, 'delete') === 0
) {
$this->countWrites++;
} else {
Expand All @@ -59,7 +58,7 @@ public function log($level, $message, array $context = []): void
echo " \n! \033[31m" . $message . "\033[0m";
} elseif ($level == LogLevel::ALERT) {
echo " \n! \033[35m" . $message . "\033[0m";
} elseif (strpos($message, 'SHOW') === 0) {
} elseif (\strpos($message, 'SHOW') === 0) {
echo " \n> \033[34m" . $message . "\033[0m";
} else {
if ($this->isPostgresSystemQuery($message)) {
Expand All @@ -68,9 +67,9 @@ public function log($level, $message, array $context = []): void
return;
}

if (strpos($message, 'SELECT') === 0) {
if (\strpos($message, 'SELECT') === 0) {
echo " \n> \033[32m" . $message . "\033[0m";
} elseif (strpos($message, 'INSERT') === 0) {
} elseif (\strpos($message, 'INSERT') === 0) {
echo " \n> \033[36m" . $message . "\033[0m";
} else {
echo " \n> \033[33m" . $message . "\033[0m";
Expand All @@ -90,14 +89,14 @@ public function hide(): void

protected function isPostgresSystemQuery(string $query): bool
{
$query = strtolower($query);
$query = \strtolower($query);
return (bool) (
strpos($query, 'tc.constraint_name') ||
strpos($query, 'pg_indexes') ||
strpos($query, 'tc.constraint_name') ||
strpos($query, 'pg_constraint') ||
strpos($query, 'information_schema') ||
strpos($query, 'pg_class')
\strpos($query, 'tc.constraint_name') ||
\strpos($query, 'pg_indexes') ||
\strpos($query, 'tc.constraint_name') ||
\strpos($query, 'pg_constraint') ||
\strpos($query, 'information_schema') ||
\strpos($query, 'pg_class')
)


Expand Down
5 changes: 2 additions & 3 deletions tests/ORM/Fixtures/TimestampedMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
use Cycle\ORM\Heap\Node;
use Cycle\ORM\Heap\State;
use Cycle\ORM\Mapper\Mapper;
use DateTimeImmutable;

class TimestampedMapper extends Mapper
{
public function queueCreate($entity, Node $node, State $state): CommandInterface
{
$cmd = parent::queueCreate($entity, $node, $state);

$dt = new DateTimeImmutable();
$dt = new \DateTimeImmutable();
$state->register('created_at', $dt);
$state->register('updated_at', $dt);

Expand All @@ -30,7 +29,7 @@ public function queueUpdate($entity, Node $node, State $state): CommandInterface
/** @var Update $cmd */
$cmd = parent::queueUpdate($entity, $node, $state);

$cmd->registerAppendix('updated_at', new DateTimeImmutable());
$cmd->registerAppendix('updated_at', new \DateTimeImmutable());

return $cmd;
}
Expand Down
Loading

0 comments on commit 9335a89

Please sign in to comment.