Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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).",
Expand Down
14 changes: 7 additions & 7 deletions tests/TestCase/IdentityDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
Expand Down Expand Up @@ -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.');
Expand All @@ -92,15 +92,15 @@ 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();
}

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']));
Expand All @@ -117,15 +117,15 @@ 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());
}

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());
Expand All @@ -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));
Expand Down
22 changes: 11 additions & 11 deletions tests/TestCase/Middleware/AuthorizationMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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);
Expand All @@ -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,
]);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();

Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Policy/OrmResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down