Skip to content

Commit

Permalink
revert rector changes
Browse files Browse the repository at this point in the history
  • Loading branch information
berkut1 committed Jun 11, 2024
1 parent 6bd3f5e commit 42e93dc
Show file tree
Hide file tree
Showing 47 changed files with 392 additions and 395 deletions.
54 changes: 28 additions & 26 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
use Rector\Php82\Rector\Class_\ReadOnlyClassRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
use Rector\PHPUnit\Rector\Class_\PreferPHPUnitSelfCallRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Symfony\CodeQuality\Rector\BinaryOp\ResponseStatusCodeRector;
Expand All @@ -29,6 +29,26 @@
__DIR__ . '/tests',
__DIR__ . '/translations',
]);

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_83,

DoctrineSetList::DOCTRINE_DBAL_40,
DoctrineSetList::DOCTRINE_ORM_214,
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
DoctrineSetList::DOCTRINE_CODE_QUALITY,

SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES,
SymfonySetList::SYMFONY_64,
SymfonySetList::SYMFONY_CODE_QUALITY,
SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,

PHPUnitSetList::PHPUNIT_100,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
]);

$rectorConfig->skip([
__DIR__ . '/src/Kernel.php',
__DIR__ . '/src/EntityFromDB',
Expand All @@ -50,7 +70,6 @@
__DIR__ . '/src/Model/User/Entity',
],
ReadOnlyClassRector::class, //buggy
PreferPHPUnitThisCallRector::class,
AssertSameResponseCodeWithDebugContentsRector::class, //TODO: remove ? https://github.com/rectorphp/rector-symfony/blob/main/docs/rector_rules_overview.md#assertsameresponsecodewithdebugcontentsrector
ResponseStatusCodeRector::class => [
__DIR__ . '/tests',
Expand All @@ -60,29 +79,12 @@
],
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
$rectorConfig->rule(CommandPropertyToAttributeRector::class);
$rectorConfig->rule(FormIsValidRector::class);
$rectorConfig->rule(ResponseStatusCodeRector::class);
$rectorConfig->rule(ParamConverterAttributeToMapEntityAttributeRector::class); //from Symfony 5.4 to 6.4

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_83,

DoctrineSetList::DOCTRINE_DBAL_40,
DoctrineSetList::DOCTRINE_ORM_214,
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
DoctrineSetList::DOCTRINE_CODE_QUALITY,

SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES,
SymfonySetList::SYMFONY_64,
SymfonySetList::SYMFONY_CODE_QUALITY,
SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,

PHPUnitSetList::PHPUNIT_100,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
$rectorConfig->rules([
PreferPHPUnitSelfCallRector::class,
InlineConstructorDefaultToPropertyRector::class,
CommandPropertyToAttributeRector::class,
FormIsValidRector::class,
ResponseStatusCodeRector::class,
ParamConverterAttributeToMapEntityAttributeRector::class, //from Symfony 5.4 to 6.4
]);
};
2 changes: 1 addition & 1 deletion tests/Command/User/CreateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function testExecute(): void

// Check if the command output contains 'Done!'
$output = $commandTester->getDisplay();
$this->assertStringContainsString('Done!', $output);
self::assertStringContainsString('Done!', $output);
}

#[\Override]
Expand Down
26 changes: 13 additions & 13 deletions tests/Functional/ControlPanel/Locations/CreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public function testGuest(): void
{
$this->client->request('GET', '/locations/create');

$this->assertSame(302, $this->client->getResponse()->getStatusCode());
$this->assertSame('/login', $this->client->getResponse()->headers->get('Location'));
self::assertSame(302, $this->client->getResponse()->getStatusCode());
self::assertSame('/login', $this->client->getResponse()->headers->get('Location'));
}

public function testUser(): void
Expand All @@ -21,16 +21,16 @@ public function testUser(): void

$this->client->request('GET', '/locations/create');

$this->assertSame(403, $this->client->getResponse()->getStatusCode());
self::assertSame(403, $this->client->getResponse()->getStatusCode());
}

public function testGet(): void
{
$this->loginAs('test_admin');
$crawler = $this->client->request('GET', '/locations/create');

$this->assertSame(200, $this->client->getResponse()->getStatusCode());
$this->assertStringContainsString('Add Location', $crawler->filter('title')->text());
self::assertSame(200, $this->client->getResponse()->getStatusCode());
self::assertStringContainsString('Add Location', $crawler->filter('title')->text());
}

public function testCreate(): void
Expand All @@ -42,13 +42,13 @@ public function testCreate(): void
'form[name]' => 'Test Location',
]);

$this->assertSame(302, $this->client->getResponse()->getStatusCode());
self::assertSame(302, $this->client->getResponse()->getStatusCode());

$crawler = $this->client->followRedirect();

$this->assertSame(200, $this->client->getResponse()->getStatusCode());
$this->assertStringContainsString('Locations', $crawler->filter('title')->text());
$this->assertStringContainsString('Test Location', $crawler->filter('body')->text());
self::assertSame(200, $this->client->getResponse()->getStatusCode());
self::assertStringContainsString('Locations', $crawler->filter('title')->text());
self::assertStringContainsString('Test Location', $crawler->filter('body')->text());
}

public function testNotValid(): void
Expand All @@ -60,8 +60,8 @@ public function testNotValid(): void
'form[name]' => '',
]);

$this->assertSame(200, $this->client->getResponse()->getStatusCode());
$this->assertStringContainsString('This value should not be blank.', $crawler
self::assertSame(200, $this->client->getResponse()->getStatusCode());
self::assertStringContainsString('This value should not be blank.', $crawler
->filter('#form_name')->ancestors()->first()->filter('.invalid-feedback')->text());
}

Expand All @@ -74,8 +74,8 @@ public function testExists(): void
'form[name]' => 'Exist Test Location',
]);

$this->assertSame(200, $this->client->getResponse()->getStatusCode());
self::assertSame(200, $this->client->getResponse()->getStatusCode());

$this->assertStringContainsString('Location with this name already exists.', $crawler->filter('.alert.alert-danger')->text());
self::assertStringContainsString('Location with this name already exists.', $crawler->filter('.alert.alert-danger')->text());
}
}
10 changes: 5 additions & 5 deletions tests/Functional/ControlPanel/Locations/IndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ public function testGuest(): void
{
$this->client->request('GET', '/locations');

$this->assertSame(302, $this->client->getResponse()->getStatusCode());
$this->assertSame('/login', $this->client->getResponse()->headers->get('Location'));
self::assertSame(302, $this->client->getResponse()->getStatusCode());
self::assertSame('/login', $this->client->getResponse()->headers->get('Location'));
}

public function testUser(): void
{
$this->loginAs('test_user');

$this->client->request('GET', '/locations');
$this->assertSame(403, $this->client->getResponse()->getStatusCode());
self::assertSame(403, $this->client->getResponse()->getStatusCode());
}

public function testAdmin(): void
{
$this->loginAs('test_admin');
$crawler = $this->client->request('GET', '/locations');
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
$this->assertStringContainsString('Locations', $crawler->filter('title')->text());
self::assertSame(200, $this->client->getResponse()->getStatusCode());
self::assertStringContainsString('Locations', $crawler->filter('title')->text());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public function testGuest(): void
{
$this->client->request('GET', '/packages/virtual-machines/create');

$this->assertSame(302, $this->client->getResponse()->getStatusCode());
$this->assertSame('/login', $this->client->getResponse()->headers->get('Location'));
self::assertSame(302, $this->client->getResponse()->getStatusCode());
self::assertSame('/login', $this->client->getResponse()->headers->get('Location'));
}

public function testUser(): void
Expand All @@ -21,16 +21,16 @@ public function testUser(): void

$this->client->request('GET', '/packages/virtual-machines/create');

$this->assertSame(403, $this->client->getResponse()->getStatusCode());
self::assertSame(403, $this->client->getResponse()->getStatusCode());
}

public function testGet(): void
{
$this->loginAs('test_admin');
$crawler = $this->client->request('GET', '/packages/virtual-machines/create');

$this->assertSame(200, $this->client->getResponse()->getStatusCode());
$this->assertStringContainsString('Add Virtual Machine Package', $crawler->filter('title')->text());
self::assertSame(200, $this->client->getResponse()->getStatusCode());
self::assertStringContainsString('Add Virtual Machine Package', $crawler->filter('title')->text());
}

public function testCreate(): void
Expand All @@ -48,13 +48,13 @@ public function testCreate(): void
'form[iops_max]' => 3000,
]);

$this->assertSame(302, $this->client->getResponse()->getStatusCode());
self::assertSame(302, $this->client->getResponse()->getStatusCode());

$crawler = $this->client->followRedirect();

$this->assertSame(200, $this->client->getResponse()->getStatusCode());
$this->assertStringContainsString('Virtual Machine Packages', $crawler->filter('title')->text());
$this->assertStringContainsString('Test VM Package RDP23', $crawler->filter('body')->text());
self::assertSame(200, $this->client->getResponse()->getStatusCode());
self::assertStringContainsString('Virtual Machine Packages', $crawler->filter('title')->text());
self::assertStringContainsString('Test VM Package RDP23', $crawler->filter('body')->text());
}

public function testNotValid(): void
Expand All @@ -72,18 +72,18 @@ public function testNotValid(): void
'form[iops_max]' => -1,
]);

$this->assertSame(200, $this->client->getResponse()->getStatusCode());
self::assertSame(200, $this->client->getResponse()->getStatusCode());

$this->assertStringContainsString('This value should not be blank.', $crawler
self::assertStringContainsString('This value should not be blank.', $crawler
->filter('#form_name')->ancestors()->first()->filter('.invalid-feedback')->text());

$this->assertStringContainsString('This value should be positive.', $crawler
self::assertStringContainsString('This value should be positive.', $crawler
->filter('#form_cores')->ancestors()->first()->filter('.invalid-feedback')->text());

$this->assertStringContainsString('This value should not be blank.', $crawler
self::assertStringContainsString('This value should not be blank.', $crawler
->filter('#form_threads')->ancestors()->first()->filter('.invalid-feedback')->text());

$this->assertStringContainsString('This value should be either positive or zero.', $crawler
self::assertStringContainsString('This value should be either positive or zero.', $crawler
->filter('#form_iops_max')->ancestors()->first()->filter('.invalid-feedback')->text());
}

Expand All @@ -102,7 +102,7 @@ public function testExists(): void
'form[iops_max]' => 3000,
]);

$this->assertSame(200, $this->client->getResponse()->getStatusCode());
$this->assertStringContainsString('VirtualMachinePackage with this name already exists.', $crawler->filter('.alert.alert-danger')->text());
self::assertSame(200, $this->client->getResponse()->getStatusCode());
self::assertStringContainsString('VirtualMachinePackage with this name already exists.', $crawler->filter('.alert.alert-danger')->text());
}
}
36 changes: 18 additions & 18 deletions tests/Functional/ControlPanel/Packages/VirtualMachines/EditTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public function testGuest(): void
{
$this->client->request('GET', '/packages/virtual-machines/' . VmPackageFixture::EXISTING_ID . '/edit');

$this->assertSame(302, $this->client->getResponse()->getStatusCode());
$this->assertSame('/login', $this->client->getResponse()->headers->get('Location'));
self::assertSame(302, $this->client->getResponse()->getStatusCode());
self::assertSame('/login', $this->client->getResponse()->headers->get('Location'));
}

public function testUser(): void
Expand All @@ -21,16 +21,16 @@ public function testUser(): void

$this->client->request('GET', '/packages/virtual-machines/' . VmPackageFixture::EXISTING_ID . '/edit');

$this->assertSame(403, $this->client->getResponse()->getStatusCode());
self::assertSame(403, $this->client->getResponse()->getStatusCode());
}

public function testGet(): void
{
$this->loginAs('test_admin');
$crawler = $this->client->request('GET', '/packages/virtual-machines/' . VmPackageFixture::EXISTING_ID . '/edit');

$this->assertSame(200, $this->client->getResponse()->getStatusCode());
$this->assertStringContainsString('Edit Virtual Machine Package', $crawler->filter('title')->text());
self::assertSame(200, $this->client->getResponse()->getStatusCode());
self::assertStringContainsString('Edit Virtual Machine Package', $crawler->filter('title')->text());
}

public function testEdit(): void
Expand All @@ -47,16 +47,16 @@ public function testEdit(): void
'form[iops_max]' => $iops_max = 1500,
]);

$this->assertSame(302, $this->client->getResponse()->getStatusCode());
self::assertSame(302, $this->client->getResponse()->getStatusCode());

$crawler = $this->client->followRedirect();

$this->assertSame(200, $this->client->getResponse()->getStatusCode());
$this->assertStringContainsString('Exist Test VM Package RDP23', $crawler->filter('title')->text());
$this->assertStringContainsString('Cores/Threads: 1/1', $crawler->filter('body')->text());
$this->assertStringContainsString('RAM ' . $ram_mb, $crawler->filter('body')->text());
$this->assertStringContainsString('Space ' . $space_gb, $crawler->filter('body')->text());
$this->assertStringContainsString('IOPS Min: ' . $iops_min . ' / Max: ' . $iops_max, $crawler->filter('body')->text());
self::assertSame(200, $this->client->getResponse()->getStatusCode());
self::assertStringContainsString('Exist Test VM Package RDP23', $crawler->filter('title')->text());
self::assertStringContainsString('Cores/Threads: 1/1', $crawler->filter('body')->text());
self::assertStringContainsString('RAM ' . $ram_mb, $crawler->filter('body')->text());
self::assertStringContainsString('Space ' . $space_gb, $crawler->filter('body')->text());
self::assertStringContainsString('IOPS Min: ' . $iops_min . ' / Max: ' . $iops_max, $crawler->filter('body')->text());
}

public function testNotValid(): void
Expand All @@ -73,21 +73,21 @@ public function testNotValid(): void
'form[iops_max]' => null,
]);

$this->assertSame(200, $this->client->getResponse()->getStatusCode());
self::assertSame(200, $this->client->getResponse()->getStatusCode());

$this->assertStringContainsString('This value should be positive.', $crawler
self::assertStringContainsString('This value should be positive.', $crawler
->filter('#form_cores')->ancestors()->first()->filter('.invalid-feedback')->text());

$this->assertStringContainsString('This value should be positive.', $crawler
self::assertStringContainsString('This value should be positive.', $crawler
->filter('#form_threads')->ancestors()->first()->filter('.invalid-feedback')->text());

$this->assertStringContainsString('This value should not be blank.', $crawler
self::assertStringContainsString('This value should not be blank.', $crawler
->filter('#form_ram_mb')->ancestors()->first()->filter('.invalid-feedback')->text());

$this->assertStringContainsString('This value should be either positive or zero.', $crawler
self::assertStringContainsString('This value should be either positive or zero.', $crawler
->filter('#form_iops_min')->ancestors()->first()->filter('.invalid-feedback')->text());

$this->assertStringContainsString('This value should not be blank.', $crawler
self::assertStringContainsString('This value should not be blank.', $crawler
->filter('#form_iops_max')->ancestors()->first()->filter('.invalid-feedback')->text());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ public function testGuest(): void
{
$this->client->request('GET', '/packages/virtual-machines');

$this->assertSame(302, $this->client->getResponse()->getStatusCode());
$this->assertSame('/login', $this->client->getResponse()->headers->get('Location'));
self::assertSame(302, $this->client->getResponse()->getStatusCode());
self::assertSame('/login', $this->client->getResponse()->headers->get('Location'));
}

public function testUser(): void
{
$this->loginAs('test_user');

$this->client->request('GET', '/packages/virtual-machines');
$this->assertSame(403, $this->client->getResponse()->getStatusCode());
self::assertSame(403, $this->client->getResponse()->getStatusCode());
}

public function testAdmin(): void
{
$this->loginAs('test_admin');
$crawler = $this->client->request('GET', '/packages/virtual-machines');
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
$this->assertStringContainsString('Virtual Machine Packages', $crawler->filter('title')->text());
self::assertSame(200, $this->client->getResponse()->getStatusCode());
self::assertStringContainsString('Virtual Machine Packages', $crawler->filter('title')->text());
}
}
Loading

0 comments on commit 42e93dc

Please sign in to comment.