Completed
Push — master ( 6e1259...c4a3c9 )
by Nikola
02:37
created

couldNotProcessEmptyCollection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 8
loc 8
rs 9.4286
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
/*
3
 * This file is part of the Backup package, an RunOpenCode project.
4
 *
5
 * (c) 2015 RunOpenCode
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * This project is fork of "kbond/php-backup", for full credits info, please
11
 * view CREDITS file that was distributed with this source code.
12
 */
13
namespace RunOpenCode\Backup\Tests\Processor;
14
15
use Psr\Log\NullLogger;
16
use RunOpenCode\Backup\Contract\FileInterface;
17
use RunOpenCode\Backup\Event\BackupEvent;
18
use RunOpenCode\Backup\Processor\ZipArchiveProcessor;
19
use RunOpenCode\Backup\Source\GlobSource;
20
use RunOpenCode\Backup\Tests\Mockup\NullProfile;
21
use Symfony\Component\EventDispatcher\EventDispatcher;
22
23 View Code Duplication
class ZipArchiveProcessorTest extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
{
25
    /**
26
     * @test
27
     */
28
    public function zipAndCleanUp()
29
    {
30
        $source = new GlobSource(realpath(__DIR__ . '/../Fixtures/glob/globSet1') . '/*');
31
        $files = $source->fetch();
32
33
        $this->assertSame(3, count($files), 'There are 3 files to archive.');
34
35
        $processor = new ZipArchiveProcessor('archive.zip');
36
        $processor->setLogger(new NullLogger());
37
        $processor->setEventDispatcher($eventDispatcher = new EventDispatcher());
38
39
        $processedFiles = $processor->process($files);
40
41
        $this->assertSame(1, count($processedFiles), 'There is one compressed file');
42
43
        /**
44
         * @var FileInterface $processedFile
45
         */
46
        $processedFile = $processedFiles[0];
47
48
        $this->assertTrue(file_exists($processedFile->getPath()), 'Zip archive exists.');
49
50
        $eventDispatcher->dispatch(BackupEvent::TERMINATE, new BackupEvent(new NullProfile()));
51
52
        $this->assertFalse(file_exists($processedFile->getPath()), 'Zip archive is cleaned up.');
53
    }
54
55
    /**
56
     * @test
57
     *
58
     * @expectedException \RunOpenCode\Backup\Exception\ProcessorException
59
     */
60
    public function couldNotProcessEmptyCollection()
61
    {
62
        $processor = new ZipArchiveProcessor('archive.zip');
63
        $processor->setLogger(new NullLogger());
64
        $processor->setEventDispatcher($eventDispatcher = new EventDispatcher());
65
66
        $processor->process(array());
67
    }
68
69
}