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 12, 2024
1 parent ccf28fa commit a6f46a3
Show file tree
Hide file tree
Showing 271 changed files with 7,692 additions and 8,048 deletions.
3 changes: 2 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

return \Spiral\CodeStyle\Builder::create()
->include(__DIR__ . '/src')
->include(__DIR__ . '/tests')
->include(__FILE__)
->cache('./runtime/php-cs-fixer.cache')
->allowRisky()
->allowRisky(false)
->build();
1 change: 0 additions & 1 deletion src/Select/RootLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ final class RootLoader extends AbstractLoader
'load' => true,
'scope' => true,
];

private SelectQuery $query;

/**
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 {}
2 changes: 1 addition & 1 deletion tests/ORM/Fixtures/OptimisticLockMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function lock(Node $node, State $state, Update|Delete $command): Wrapp
if ($command->getAffectedRows() === 0) {
throw new \RuntimeException(sprintf(
'The `%s` record is locked.',
$node->getRole()
$node->getRole(),
));
}
});
Expand Down
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 {}
1 change: 0 additions & 1 deletion 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 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
6 changes: 2 additions & 4 deletions tests/ORM/Fixtures/TransactionTestMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ class TransactionTestMapper extends Mapper
public function queueDelete($entity, Node $node, State $state): CommandInterface
{
if ($entity->id == '3') {
return new class ($this->source->getDatabase()) implements CommandInterface {
public function __construct(private DatabaseInterface $database)
{
}
return new class($this->source->getDatabase()) implements CommandInterface {
public function __construct(private DatabaseInterface $database) {}

public function isReady(): bool
{
Expand Down
2 changes: 0 additions & 2 deletions tests/ORM/Fixtures/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ class User implements ImagedInterface
public $credentials;

public array $settings;

public ?array $settingsNullable = null;

public ?JsonSerializableClass $jsonSerializable = null;

public function __construct()
Expand Down
1 change: 0 additions & 1 deletion tests/ORM/Fixtures/UserCredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class UserCredentials
{
public $username;
public $password;

public $unmapped_public_property;
private $unmapped_private_property;
}
8 changes: 1 addition & 7 deletions tests/ORM/Fixtures/UserPersistRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,21 @@ class UserPersistRepository extends Repository
/** @var Transaction */
private $transaction;

/**
* @param Select $select
* @param ORMInterface $orm
*/
public function __construct(Select $select, ORMInterface $orm)
{
parent::__construct($select);
$this->transaction = new Transaction($orm);
}

/**
* @param User $user
* @param bool $cascade
*
* @throws \Throwable
*/
public function save(User $user, bool $cascade = true): void
{
$this->transaction->persist(
$user,
$cascade ? Transaction::MODE_CASCADE : Transaction::MODE_ENTITY_ONLY
$cascade ? Transaction::MODE_CASCADE : Transaction::MODE_ENTITY_ONLY,
);

$this->transaction->run(); // transaction is clean after run
Expand Down
5 changes: 0 additions & 5 deletions tests/ORM/Fixtures/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@

class UserRepository extends Repository
{
/**
* @param string $email
*
* @return User|null
*/
public function findByEmail(string $email): ?User
{
return $this->findOne(compact('email'));
Expand Down
Loading

0 comments on commit a6f46a3

Please sign in to comment.