Skip to content

Commit

Permalink
Rector
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Nov 13, 2024
1 parent f4e3189 commit 4eb3a40
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 27 deletions.
2 changes: 2 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

use Rector\Config\RectorConfig;
use Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\NarrowUnusedSetUpDefinedPropertyRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;
Expand All @@ -40,5 +41,6 @@
$rectorConfig->skip([
ExceptionHandlerTypehintRector::class,
PreferPHPUnitThisCallRector::class,
NarrowUnusedSetUpDefinedPropertyRector::class,
]);
};
7 changes: 1 addition & 6 deletions tests/Action/AppendFormFieldElementActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@

final class AppendFormFieldElementActionTest extends TestCase
{
/**
* @var Stub&AdminFetcherInterface
*/
private AdminFetcherInterface $adminFetcher;

/**
* @var Environment&MockObject
*/
Expand Down Expand Up @@ -101,7 +96,7 @@ public function testAppendFormFieldElementAction(): void
$response = ($this->action)($request);

static::assertInstanceOf(Response::class, $response);
static::assertSame($response->getContent(), 'block');
static::assertSame('block', $response->getContent());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Action/RetrieveFormFieldElementActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function testRetrieveFormFieldElementAction(): void
$response = ($this->action)($request);

static::assertInstanceOf(Response::class, $response);
static::assertSame($response->getContent(), 'block');
static::assertSame('block', $response->getContent());
}

/**
Expand Down
30 changes: 15 additions & 15 deletions tests/Controller/CRUDControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public function testRenderJson1(): void
$response = $this->protectedTestedMethods['renderJson']->invoke($this->controller, $data, 200, [], $this->request);

static::assertInstanceOf(JsonResponse::class, $response);
static::assertSame($response->headers->get('Content-Type'), 'application/json');
static::assertSame('application/json', $response->headers->get('Content-Type'));
static::assertSame(json_encode($data), $response->getContent());
}

Expand All @@ -324,7 +324,7 @@ public function testRenderJson2(): void
$response = $this->protectedTestedMethods['renderJson']->invoke($this->controller, $data, 200, [], $this->request);

static::assertInstanceOf(JsonResponse::class, $response);
static::assertSame($response->headers->get('Content-Type'), 'application/json');
static::assertSame('application/json', $response->headers->get('Content-Type'));
static::assertSame(json_encode($data), $response->getContent());
}

Expand All @@ -337,7 +337,7 @@ public function testRenderJsonAjax(): void
$response = $this->protectedTestedMethods['renderJson']->invoke($this->controller, $data, 200, [], $this->request);

static::assertInstanceOf(JsonResponse::class, $response);
static::assertSame($response->headers->get('Content-Type'), 'application/json');
static::assertSame('application/json', $response->headers->get('Content-Type'));
static::assertSame(json_encode($data), $response->getContent());
}

Expand Down Expand Up @@ -535,7 +535,7 @@ public function testListActionAccessDenied(): void
$this->admin->expects(static::once())
->method('checkAccess')
->with(static::equalTo('list'))
->will(static::throwException(new AccessDeniedException()));
->willThrowException(new AccessDeniedException());

$this->controller->listAction($this->request);
}
Expand Down Expand Up @@ -613,7 +613,7 @@ public function testBatchActionDeleteAccessDenied(): void
$this->admin->expects(static::once())
->method('checkAccess')
->with(static::equalTo('batchDelete'))
->will(static::throwException(new AccessDeniedException()));
->willThrowException(new AccessDeniedException());

$this->controller->batchActionDelete($this->createMock(ProxyQueryInterface::class));
}
Expand Down Expand Up @@ -787,7 +787,7 @@ public function testShowActionAccessDenied(): void
$this->admin->expects(static::once())
->method('checkAccess')
->with(static::equalTo('show'))
->will(static::throwException(new AccessDeniedException()));
->willThrowException(new AccessDeniedException());

$this->expectException(AccessDeniedException::class);

Expand Down Expand Up @@ -1003,7 +1003,7 @@ public function testDeleteActionAccessDenied(): void
$this->admin->expects(static::once())
->method('checkAccess')
->with(static::equalTo('delete'))
->will(static::throwException(new AccessDeniedException()));
->willThrowException(new AccessDeniedException());

$this->expectException(AccessDeniedException::class);

Expand Down Expand Up @@ -1591,7 +1591,7 @@ public function testEditActionAccessDenied(): void
$this->admin->expects(static::once())
->method('checkAccess')
->with(static::equalTo('edit'))
->will(static::throwException(new AccessDeniedException()));
->willThrowException(new AccessDeniedException());

$this->expectException(AccessDeniedException::class);

Expand Down Expand Up @@ -2328,7 +2328,7 @@ public function testEditActionWithLockException(): void

$this->admin
->method('update')
->will(static::throwException(new LockException()));
->willThrowException(new LockException());

$this->admin
->method('toString')
Expand All @@ -2355,7 +2355,7 @@ public function testCreateActionAccessDenied(): void
$this->admin->expects(static::once())
->method('checkAccess')
->with(static::equalTo('create'))
->will(static::throwException(new AccessDeniedException()));
->willThrowException(new AccessDeniedException());

$this->expectException(AccessDeniedException::class);

Expand Down Expand Up @@ -3052,7 +3052,7 @@ public function testExportActionAccessDenied(): void
$this->admin->expects(static::once())
->method('checkAccess')
->with(static::equalTo('export'))
->will(static::throwException(new AccessDeniedException()));
->willThrowException(new AccessDeniedException());

$this->expectException(AccessDeniedException::class);

Expand Down Expand Up @@ -3122,7 +3122,7 @@ public function testHistoryActionAccessDenied(): void
$this->admin->expects(static::once())
->method('checkAccess')
->with(static::equalTo('history'))
->will(static::throwException(new AccessDeniedException()));
->willThrowException(new AccessDeniedException());

$this->expectException(AccessDeniedException::class);
$this->controller->historyAction($this->request);
Expand Down Expand Up @@ -3273,7 +3273,7 @@ public function testAclActionAccessDenied(): void
$this->admin->expects(static::once())
->method('checkAccess')
->with(static::equalTo('acl'), static::equalTo($object))
->will(static::throwException(new AccessDeniedException()));
->willThrowException(new AccessDeniedException());

$this->expectException(AccessDeniedException::class);

Expand Down Expand Up @@ -3542,7 +3542,7 @@ public function testHistoryViewRevisionActionAccessDenied(): void
$this->admin->expects(static::once())
->method('checkAccess')
->with(static::equalTo('historyViewRevision'))
->will(static::throwException(new AccessDeniedException()));
->willThrowException(new AccessDeniedException());

$this->expectException(AccessDeniedException::class);

Expand Down Expand Up @@ -3723,7 +3723,7 @@ public function testHistoryCompareRevisionsActionAccessDenied(): void
$this->admin->expects(static::once())
->method('checkAccess')
->with(static::equalTo('historyCompareRevisions'))
->will(static::throwException(new AccessDeniedException()));
->willThrowException(new AccessDeniedException());

$this->expectException(AccessDeniedException::class);

Expand Down
4 changes: 2 additions & 2 deletions tests/EventListener/ConfigureCRUDControllerListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public function testItConfiguresCRUDController(): void
->method('addGlobal')
->willReturnCallback(static function (string $name) use ($matcher) {
match ($matcher->getInvocationCount()) {
1 => static::assertSame($name, 'admin'),
2 => static::assertSame($name, 'base_template'),
1 => static::assertSame('admin', $name),
2 => static::assertSame('base_template', $name),
default => throw new \LogicException('Exactly 2 calls'),
};
});
Expand Down
2 changes: 1 addition & 1 deletion tests/Menu/Provider/GroupMenuProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function testGetMenuProviderWithCheckerGrantedGroupRoles(array $adminGrou

$extras = $item->getExtras();
static::assertArrayHasKey('translation_domain', $extras);
static::assertSame($extras['translation_domain'], 'SonataAdminBundle');
static::assertSame('SonataAdminBundle', $extras['translation_domain']);
}

public function unanimousGrantCheckerMock(string $role): bool
Expand Down
4 changes: 2 additions & 2 deletions tests/Security/Handler/AclSecurityHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function testWithAuthenticationCredentialsNotFoundException(): void
$authorizationChecker = $this->createMock(AuthorizationCheckerInterface::class);
$authorizationChecker
->method('isGranted')
->will(static::throwException(new AuthenticationCredentialsNotFoundException('FAIL')));
->willThrowException(new AuthenticationCredentialsNotFoundException('FAIL'));

$aclProvider = $this->createMock(MutableAclProviderInterface::class);

Expand All @@ -112,7 +112,7 @@ public function testWithNonAuthenticationCredentialsNotFoundException(): void
$authorizationChecker = $this->createMock(AuthorizationCheckerInterface::class);
$authorizationChecker
->method('isGranted')
->will(static::throwException(new \RuntimeException('FAIL')));
->willThrowException(new \RuntimeException('FAIL'));

$aclProvider = $this->createMock(MutableAclProviderInterface::class);

Expand Down

0 comments on commit 4eb3a40

Please sign in to comment.