diff --git a/composer.json b/composer.json index 8b10a6f1..59accd1d 100644 --- a/composer.json +++ b/composer.json @@ -31,11 +31,11 @@ "psr/http-server-middleware": "^1.0" }, "require-dev": { - "cakephp/authentication": "^3.0", + "cakephp/authentication": "^3.0 || ^4.0", "cakephp/bake": "^3.2", "cakephp/cakephp": "^5.1", "cakephp/cakephp-codesniffer": "^5.1", - "phpunit/phpunit": "^10.5.5 || ^11.1.3" + "phpunit/phpunit": "^10.5.58 || ^11.5.3 || ^12.4 || ^13.0" }, "suggest": { "cakephp/http": "To use \"RequestPolicyInterface\" (Not needed separately if using full CakePHP framework).", diff --git a/tests/TestCase/IdentityDecoratorTest.php b/tests/TestCase/IdentityDecoratorTest.php index ab47fd38..be2a2fb0 100644 --- a/tests/TestCase/IdentityDecoratorTest.php +++ b/tests/TestCase/IdentityDecoratorTest.php @@ -35,7 +35,7 @@ public static function constructorDataProvider() #[DataProvider('constructorDataProvider')] public function testConstructorAccepted($data) { - $auth = $this->createMock(AuthorizationServiceInterface::class); + $auth = $this->createStub(AuthorizationServiceInterface::class); $identity = new IdentityDecorator($auth, $data); $this->assertSame($data['id'], $identity['id']); } @@ -82,7 +82,7 @@ public function testApplyScopeAdditionalParams() public function testCall() { $data = new Article(['id' => 1]); - $auth = $this->createMock(AuthorizationServiceInterface::class); + $auth = $this->createStub(AuthorizationServiceInterface::class); $identity = new IdentityDecorator($auth, $data); $this->assertFalse(method_exists($identity, 'isDirty'), 'method not defined on decorator'); $this->assertTrue($identity->isDirty('id'), 'method is callable though.'); @@ -92,7 +92,7 @@ public function testCallArray() { $this->expectException(BadMethodCallException::class); $data = ['id' => 1]; - $auth = $this->createMock(AuthorizationServiceInterface::class); + $auth = $this->createStub(AuthorizationServiceInterface::class); $identity = new IdentityDecorator($auth, $data); $identity->boom(); } @@ -100,7 +100,7 @@ public function testCallArray() public function testArrayAccessImplementation() { $data = new ArrayObject(['id' => 1]); - $auth = $this->createMock(AuthorizationServiceInterface::class); + $auth = $this->createStub(AuthorizationServiceInterface::class); $identity = new IdentityDecorator($auth, $data); $this->assertTrue(isset($identity['id'])); @@ -117,7 +117,7 @@ public function testArrayAccessImplementation() public function testGetOriginalData() { $data = ['id' => 2]; - $auth = $this->createMock(AuthorizationServiceInterface::class); + $auth = $this->createStub(AuthorizationServiceInterface::class); $identity = new IdentityDecorator($auth, $data); $this->assertSame($data, $identity->getOriginalData()); } @@ -125,7 +125,7 @@ public function testGetOriginalData() public function testGetOriginalDataWrappedObjectHasOriginalData() { $data = ['id' => 2]; - $auth = $this->createMock(AuthorizationServiceInterface::class); + $auth = $this->createStub(AuthorizationServiceInterface::class); $inner = new IdentityDecorator($auth, $data); $identity = new IdentityDecorator($auth, $inner); $this->assertSame($data, $identity->getOriginalData()); @@ -134,7 +134,7 @@ public function testGetOriginalDataWrappedObjectHasOriginalData() public function testGetProperty() { $data = new Article(['id' => 2]); - $auth = $this->createMock(AuthorizationServiceInterface::class); + $auth = $this->createStub(AuthorizationServiceInterface::class); $identity = new IdentityDecorator($auth, $data); $this->assertTrue(isset($identity->id)); diff --git a/tests/TestCase/Middleware/AuthorizationMiddlewareTest.php b/tests/TestCase/Middleware/AuthorizationMiddlewareTest.php index 4446b36c..c7ffeed8 100644 --- a/tests/TestCase/Middleware/AuthorizationMiddlewareTest.php +++ b/tests/TestCase/Middleware/AuthorizationMiddlewareTest.php @@ -42,7 +42,7 @@ class AuthorizationMiddlewareTest extends TestCase { public function testInvokeService() { - $service = $this->createMock(AuthorizationServiceInterface::class); + $service = $this->createStub(AuthorizationServiceInterface::class); $request = new ServerRequest(); $handler = new TestRequestHandler(function ($request) use ($service) { $this->assertInstanceOf(ServerRequestInterface::class, $request); @@ -80,7 +80,7 @@ public function testInvokeAuthorizationRequiredError() public function testInvokeApp() { - $service = $this->createMock(AuthorizationServiceInterface::class); + $service = $this->createStub(AuthorizationServiceInterface::class); $provider = $this->createMock(AuthorizationServiceProviderInterface::class); $provider ->expects($this->once()) @@ -110,7 +110,7 @@ public function testInvokeServiceWithIdentity() 'id' => 1, ]); - $service = $this->createMock(AuthorizationServiceInterface::class); + $service = $this->createStub(AuthorizationServiceInterface::class); $request = (new ServerRequest())->withAttribute('identity', $identity); $handler = new TestRequestHandler(function ($request) use ($service) { $this->assertInstanceOf(RequestInterface::class, $request); @@ -130,7 +130,7 @@ public function testInvokeServiceWithIdentity() public function testIdentityInstance() { - $service = $this->createMock(AuthorizationServiceInterface::class); + $service = $this->createStub(AuthorizationServiceInterface::class); $identity = new IdentityDecorator($service, [ 'id' => 1, ]); @@ -155,7 +155,7 @@ public function testCustomIdentity() 'id' => 1, ]; - $service = $this->createMock(AuthorizationServiceInterface::class); + $service = $this->createStub(AuthorizationServiceInterface::class); $request = (new ServerRequest())->withAttribute('user', $identity); $handler = new TestRequestHandler(function ($request) use ($service) { $this->assertInstanceOf(RequestInterface::class, $request); @@ -183,7 +183,7 @@ public function testCustomIdentityDecorator() 'id' => 1, ]); - $service = $this->createMock(AuthorizationServiceInterface::class); + $service = $this->createStub(AuthorizationServiceInterface::class); $request = (new ServerRequest())->withAttribute('identity', $identity); $handler = new TestRequestHandler(function ($request) use ($service, $identity) { $this->assertInstanceOf(RequestInterface::class, $request); @@ -212,7 +212,7 @@ public function testInvalidIdentity() 'id' => 1, ]; - $service = $this->createMock(AuthorizationServiceInterface::class); + $service = $this->createStub(AuthorizationServiceInterface::class); $request = (new ServerRequest())->withAttribute('identity', $identity); $handler = new TestRequestHandler(); @@ -229,7 +229,7 @@ public function testInvalidIdentity() public function testUnauthorizedHandler() { - $service = $this->createMock(AuthorizationServiceInterface::class); + $service = $this->createStub(AuthorizationServiceInterface::class); $request = new ServerRequest(); $handler = new TestRequestHandler(function () { throw new Exception(); @@ -243,7 +243,7 @@ public function testUnauthorizedHandler() public function testUnauthorizedHandlerSuppress() { - $service = $this->createMock(AuthorizationServiceInterface::class); + $service = $this->createStub(AuthorizationServiceInterface::class); $request = new ServerRequest(); $handler = new TestRequestHandler(function () { throw new Exception(); @@ -260,7 +260,7 @@ public function testUnauthorizedHandlerSuppress() public function testUnauthorizedHandlerRequireAuthz() { - $service = $this->createMock(AuthorizationServiceInterface::class); + $service = $this->createStub(AuthorizationServiceInterface::class); $request = new ServerRequest(); $handler = new TestRequestHandler(function () { throw new Exception(); @@ -301,7 +301,7 @@ public function testMiddlewareInjectsServiceIntoDICViaCustomContainerInstance() ); $handler = new TestRequestHandler(); - $service = $this->createMock(AuthorizationServiceInterface::class); + $service = $this->createStub(AuthorizationServiceInterface::class); $provider = $this->createMock(AuthorizationServiceProviderInterface::class); $provider ->expects($this->once()) diff --git a/tests/TestCase/Policy/Exception/MissingPolicyExceptionTest.php b/tests/TestCase/Policy/Exception/MissingPolicyExceptionTest.php index 2d8d8737..005607aa 100644 --- a/tests/TestCase/Policy/Exception/MissingPolicyExceptionTest.php +++ b/tests/TestCase/Policy/Exception/MissingPolicyExceptionTest.php @@ -27,7 +27,7 @@ class MissingPolicyExceptionTest extends TestCase public function testConstructQueryInstance(): void { $articles = new ArticlesTable(); - $query = $this->createMock(QueryInterface::class); + $query = $this->createStub(QueryInterface::class); $query->method('getRepository') ->willReturn($articles); $missingPolicyException = new MissingPolicyException($query); diff --git a/tests/TestCase/Policy/OrmResolverTest.php b/tests/TestCase/Policy/OrmResolverTest.php index 89056a14..b3801d0c 100644 --- a/tests/TestCase/Policy/OrmResolverTest.php +++ b/tests/TestCase/Policy/OrmResolverTest.php @@ -119,7 +119,7 @@ public function testGetPolicyUnknownTable() { $this->expectException(MissingPolicyException::class); - $articles = $this->createMock('Cake\Datasource\RepositoryInterface'); + $articles = $this->createStub('Cake\Datasource\RepositoryInterface'); $resolver = new OrmResolver('TestApp'); $resolver->getPolicy($articles); }