Passed
Push — master ( 240c83...03f39b )
by Mathias
06:41
created

FileProcessorTest::assertFileMigrated()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
dl 0
loc 7
rs 10
c 1
b 0
f 1
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yawik\Migration\Tests\Migrator\Version36;
6
7
use CoreTestUtils\TestCase\FunctionalTestCase;
0 ignored issues
show
Bug introduced by
The type CoreTestUtils\TestCase\FunctionalTestCase was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Symfony\Component\Console\Output\StreamOutput;
9
use Yawik\Migration\Migrator\Version36\FileProcessor;
10
use Yawik\Migration\Tests\DatabaseConcernTrait;
11
12
/**
13
 * Class FileProcessorTest
14
 *
15
 * @covers \Yawik\Migration\Migrator\Version36\FileProcessor
16
 * @package Yawik\Migration\Tests\Migrator\Version36
17
 */
18
class FileProcessorTest extends FunctionalTestCase
19
{
20
    use DatabaseConcernTrait;
21
22
    public function setUp(): void
23
    {
24
        parent::setUp();
25
        $this->initialize($this->getApplicationServiceLocator());
26
    }
27
28
    private function createData()
29
    {
30
        $bucket = $this->getBucket('test.files');
31
        $this->drop('test');
32
        $bucket->drop();
33
34
35
        $this->createFile('test');
36
        $this->createFile('test');
37
        $this->createFile("test");
38
        $this->createFile('test');
39
    }
40
41
    private function createProcessor()
42
    {
43
        $stream = fopen('php://memory', 'w', \false);
44
45
        return new FileProcessor(
46
            $this->getDoctrine(),
47
            new StreamOutput($stream),
48
            'test'
49
        );
50
    }
51
52
    public function testProcess()
53
    {
54
        $this->createData();
55
        $target = $this->createProcessor();
56
        $target->process();
57
58
        $bucket = $this->getBucket('test');
59
        $cursor = $bucket->find();
60
        foreach($cursor as $current){
61
            $this->assertFileMigrated($current);
62
        }
63
    }
64
65
    protected function assertFileMigrated(array $file)
66
    {
67
        $bucket = $this->getBucket('test.files');
0 ignored issues
show
Unused Code introduced by
The assignment to $bucket is dead and can be removed.
Loading history...
68
        $this->assertNotNull($file);
69
        $this->assertNotNull($this->getNamespacedValue('metadata', $file));
70
        $this->assertNull($this->getNamespacedValue('dateuploaded', $file));
71
        $this->assertNull($this->getNamespacedValue('permissions', $file));
72
    }
73
}