1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kami\ApiCoreBundle\Tests\RequestProcessor\Step\Common; |
4
|
|
|
|
5
|
|
|
use JMS\Serializer\Serializer; |
6
|
|
|
use Kami\ApiCoreBundle\RequestProcessor\Step\Common\GetReflectionFromRequestStep; |
7
|
|
|
use Kami\ApiCoreBundle\RequestProcessor\Step\Common\PersistStep; |
8
|
|
|
use Kami\ApiCoreBundle\RequestProcessor\Step\Common\ValidateFormStep; |
9
|
|
|
use Kami\ApiCoreBundle\RequestProcessor\Step\Common\ValidateResourceAccessStep; |
10
|
|
|
use Kami\ApiCoreBundle\Security\AccessManager; |
11
|
|
|
use Kami\ApiCoreBundle\Tests\Entity\MyModel; |
12
|
|
|
use Kami\Component\RequestProcessor\Artifact; |
13
|
|
|
use Kami\Component\RequestProcessor\ArtifactCollection; |
14
|
|
|
use PHPUnit\Framework\TestCase; |
15
|
|
|
use Symfony\Component\HttpFoundation\Request; |
16
|
|
|
use Kami\ApiCoreBundle\RequestProcessor\ProcessorResponse; |
|
|
|
|
17
|
|
|
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; |
18
|
|
|
|
19
|
|
|
class ValidateResourceAccessStepTest extends TestCase |
20
|
|
|
{ |
21
|
|
|
|
22
|
|
|
public function testCanBeConstructed() |
23
|
|
|
{ |
24
|
|
|
$accessManagerMock = $this->createMock(AccessManager::class); |
25
|
|
|
|
26
|
|
|
$step = new ValidateResourceAccessStep($accessManagerMock); |
27
|
|
|
$this->assertInstanceOf(ValidateResourceAccessStep::class, $step); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function testExecute() |
31
|
|
|
{ |
32
|
|
|
$accessManagerMock = $this->createMock(AccessManager::class); |
33
|
|
|
$accessManagerMock->method('canAccessResource')->willReturn(true); |
|
|
|
|
34
|
|
|
$step = new ValidateResourceAccessStep($accessManagerMock); |
35
|
|
|
|
36
|
|
|
$step->setArtifacts(new ArtifactCollection([ |
37
|
|
|
new Artifact('reflection', new \ReflectionClass(MyModel::class)) |
38
|
|
|
])); |
39
|
|
|
|
40
|
|
|
$artifacts = $step->execute(new Request()); |
41
|
|
|
|
42
|
|
|
$this->assertInstanceOf(ArtifactCollection::class, $artifacts); |
43
|
|
|
$this->assertTrue(true, $artifacts->get('access_granted')->getValue()); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function testGetRequiredArtifacts() |
47
|
|
|
{ |
48
|
|
|
$accessManagerMock = $this->createMock(AccessManager::class); |
49
|
|
|
$step = new ValidateResourceAccessStep($accessManagerMock); |
50
|
|
|
|
51
|
|
|
$this->assertEquals(['reflection'], $step->getRequiredArtifacts()); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths