Completed
Pull Request — master (#1)
by Harry
04:52
created

testGetDeCompressorForRandomWillThrowAnException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Graze\DataFile\Test\Unit\Modify\Compress;
4
5
use Graze\DataFile\Modify\Compress\CompressionFactory;
6
use Graze\DataFile\Modify\Compress\Gzip;
7
use Graze\DataFile\Modify\Compress\Zip;
8
use Graze\DataFile\Modify\Exception\InvalidCompressionTypeException;
9
use Graze\DataFile\Test\TestCase;
10
11
class CompressionFactoryTest extends TestCase
12
{
13
    /**
14
     * @var CompressionFactory
15
     */
16
    private $factory;
17
18
    public function setUp()
19
    {
20
        $this->factory = new CompressionFactory();
21
    }
22
23 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...
24
    {
25
        $object = $this->factory->getCompressor(Gzip::NAME);
26
        static::assertInstanceOf(Gzip::class, $object);
27
        $object = $this->factory->getDeCompressor(Gzip::NAME);
28
        static::assertInstanceOf(Gzip::class, $object);
29
    }
30
31 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...
32
    {
33
        $object = $this->factory->getCompressor(Zip::NAME);
34
        static::assertInstanceOf(Zip::class, $object);
35
        $object = $this->factory->getDeCompressor(Zip::NAME);
36
        static::assertInstanceOf(Zip::class, $object);
37
    }
38
39
    public function testGetCompressorForNoneWillThrowAnException()
40
    {
41
        $this->expectException(InvalidCompressionTypeException::class);
42
        $this->factory->getCompressor(CompressionFactory::TYPE_NONE);
43
    }
44
45
    public function testGetDeCompressorForNoneWillThrowAnException()
46
    {
47
        $this->expectException(InvalidCompressionTypeException::class);
48
        $this->factory->getDeCompressor(CompressionFactory::TYPE_NONE);
49
    }
50
51
    public function testGetCompressorForUnknownWillThrowAnException()
52
    {
53
        $this->expectException(InvalidCompressionTypeException::class);
54
        $this->factory->getCompressor(CompressionFactory::TYPE_UNKNOWN);
55
    }
56
57
    public function testGetDeCompressorForUnknownWillThrowAnException()
58
    {
59
        $this->expectException(InvalidCompressionTypeException::class);
60
        $this->factory->getDeCompressor(CompressionFactory::TYPE_UNKNOWN);
61
    }
62
63
    public function testGetCompressorForRandomWillThrowAnException()
64
    {
65
        $this->expectException(InvalidCompressionTypeException::class);
66
        $this->factory->getCompressor('random');
67
    }
68
69
    public function testGetDeCompressorForRandomWillThrowAnException()
70
    {
71
        $this->expectException(InvalidCompressionTypeException::class);
72
        $this->factory->getDeCompressor('random');
73
    }
74
75
    public function testIsCompression()
76
    {
77
        static::assertTrue($this->factory->isCompression(Gzip::NAME));
78
        static::assertTrue($this->factory->isCompression(Zip::NAME));
79
        static::assertFalse($this->factory->isCompression('lzop'));
80
    }
81
}
82