1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Kami\ApiCoreBundle\Tests\RequestProcessor\Step\Common; |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
use Doctrine\Bundle\DoctrineBundle\Registry; |
8
|
|
|
use Doctrine\ORM\EntityManager; |
9
|
|
|
use Doctrine\ORM\QueryBuilder; |
10
|
|
|
use Kami\ApiCoreBundle\RequestProcessor\ProcessorResponse; |
|
|
|
|
11
|
|
|
use Kami\ApiCoreBundle\RequestProcessor\Step\Common\PersistStep; |
12
|
|
|
use Kami\ApiCoreBundle\RequestProcessor\Step\Common\ValidateFormStep; |
13
|
|
|
use Kami\ApiCoreBundle\Tests\Entity\MyModel; |
14
|
|
|
use Kami\Component\RequestProcessor\Artifact; |
15
|
|
|
use Kami\Component\RequestProcessor\ArtifactCollection; |
16
|
|
|
use PHPUnit\Framework\TestCase; |
17
|
|
|
use Symfony\Component\HttpFoundation\Request; |
18
|
|
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; |
19
|
|
|
|
20
|
|
|
class PersistStepTest extends TestCase |
21
|
|
|
{ |
22
|
|
|
public function testCanBeConstructed() |
23
|
|
|
{ |
24
|
|
|
$this->assertInstanceOf(PersistStep::class, new PersistStep($this->createMock(Registry::class))); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function testExecute() |
28
|
|
|
{ |
29
|
|
|
$entityManagerMock = $this->createMock(EntityManager::class); |
30
|
|
|
|
31
|
|
|
$registryMock = $this->createMock(Registry::class); |
32
|
|
|
$registryMock->expects($this->at(0))->method('getManager')->willReturn($entityManagerMock); |
33
|
|
|
|
34
|
|
|
$step = new PersistStep($registryMock); |
35
|
|
|
$step->setArtifacts(new ArtifactCollection([ |
36
|
|
|
new Artifact('entity', new MyModel()), |
37
|
|
|
new Artifact('validation', true), |
38
|
|
|
new Artifact('query_builder', new QueryBuilder($this->createMock(EntityManager::class))) |
39
|
|
|
])); |
40
|
|
|
|
41
|
|
|
$artifacts = $step->execute(new Request()); |
42
|
|
|
$this->assertInstanceOf(ArtifactCollection::class, $artifacts); |
43
|
|
|
$this->assertEquals(200, $artifacts->get('status')->getValue()); |
44
|
|
|
$this->assertInstanceOf(MyModel::class, $artifacts->get('response_data')->getValue()); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function testGetRequiredArtifacts() |
48
|
|
|
{ |
49
|
|
|
$step = new PersistStep($this->createMock(Registry::class)); |
50
|
|
|
|
51
|
|
|
$this->assertEquals(['validation', 'entity', 'access_granted'], $step->getRequiredArtifacts()); |
52
|
|
|
} |
53
|
|
|
} |
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