Completed
Pull Request — master (#3)
by Harry
03:17
created

CompressionFactoryTest::testIsCompression()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of graze/data-file
4
 *
5
 * Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license https://github.com/graze/data-file/blob/master/LICENSE.md
11
 * @link    https://github.com/graze/data-file
12
 */
13
14
namespace Graze\DataFile\Test\Unit\Modify\Compress;
15
16
use Graze\DataFile\Modify\Compress\CompressionFactory;
17
use Graze\DataFile\Modify\Compress\Gzip;
18
use Graze\DataFile\Modify\Compress\Zip;
19
use Graze\DataFile\Modify\Exception\InvalidCompressionTypeException;
20
use Graze\DataFile\Test\TestCase;
21
22
class CompressionFactoryTest extends TestCase
23
{
24
    /**
25
     * @var CompressionFactory
26
     */
27
    private $factory;
28
29
    public function setUp()
30
    {
31
        $this->factory = new CompressionFactory();
32
    }
33
34 View Code Duplication
    public function testGetCompressorForGzipReturnsGzip()
0 ignored issues
show
Duplication introduced by
This method 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...
35
    {
36
        $object = $this->factory->getCompressor(Gzip::NAME);
37
        static::assertInstanceOf(Gzip::class, $object);
38
        $object = $this->factory->getDeCompressor(Gzip::NAME);
39
        static::assertInstanceOf(Gzip::class, $object);
40
    }
41
42 View Code Duplication
    public function testGetCompressorForZipReturnsZip()
0 ignored issues
show
Duplication introduced by
This method 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...
43
    {
44
        $object = $this->factory->getCompressor(Zip::NAME);
45
        static::assertInstanceOf(Zip::class, $object);
46
        $object = $this->factory->getDeCompressor(Zip::NAME);
47
        static::assertInstanceOf(Zip::class, $object);
48
    }
49
50
    public function testGetCompressorForNoneWillThrowAnException()
51
    {
52
        $this->expectException(InvalidCompressionTypeException::class);
53
        $this->factory->getCompressor(CompressionFactory::TYPE_NONE);
54
    }
55
56
    public function testGetDeCompressorForNoneWillThrowAnException()
57
    {
58
        $this->expectException(InvalidCompressionTypeException::class);
59
        $this->factory->getDeCompressor(CompressionFactory::TYPE_NONE);
60
    }
61
62
    public function testGetCompressorForUnknownWillThrowAnException()
63
    {
64
        $this->expectException(InvalidCompressionTypeException::class);
65
        $this->factory->getCompressor(CompressionFactory::TYPE_UNKNOWN);
66
    }
67
68
    public function testGetDeCompressorForUnknownWillThrowAnException()
69
    {
70
        $this->expectException(InvalidCompressionTypeException::class);
71
        $this->factory->getDeCompressor(CompressionFactory::TYPE_UNKNOWN);
72
    }
73
74
    public function testGetCompressorForRandomWillThrowAnException()
75
    {
76
        $this->expectException(InvalidCompressionTypeException::class);
77
        $this->factory->getCompressor('random');
78
    }
79
80
    public function testGetDeCompressorForRandomWillThrowAnException()
81
    {
82
        $this->expectException(InvalidCompressionTypeException::class);
83
        $this->factory->getDeCompressor('random');
84
    }
85
86
    public function testIsCompression()
87
    {
88
        static::assertTrue($this->factory->isCompression(Gzip::NAME));
89
        static::assertTrue($this->factory->isCompression(Zip::NAME));
90
        static::assertFalse($this->factory->isCompression('lzop'));
91
    }
92
}
93