Completed
Push — master ( 6f4e11...e12aed )
by Matthijs
11:15 queued 07:09
created

MimeTypeFilterTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 6
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testMimeTypeFilter() 0 9 1
A setUp() 0 9 1
1
<?php
2
3
/*
4
 * This file is part of the Spider package.
5
 *
6
 * (c) Matthijs van den Bos <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace VDB\Spider\Tests\Discoverer;
13
14
use GuzzleHttp\Psr7\Response;
15
use VDB\Spider\Resource;
16
use VDB\Spider\Tests\TestCase;
17
use VDB\Spider\Uri\DiscoveredUri;
18
use VDB\Spider\Filter\Postfetch\MimeTypeFilter;
19
use VDB\Uri\Uri;
20
21
class MimeTypeFilterTest extends TestCase
22
{
23
    /** @var Resource */
24
    protected $spiderResource;
25
26
    /** @var DiscoveredUri */
27
    protected $uri;
28
29
    protected function setUp()
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...
30
    {
31
        $this->uri = new DiscoveredUri(new Uri('http://foobar.com/image.jpg'));
32
33
        $this->spiderResource = new Resource(
34
            $this->uri,
35
            new Response(200, ['Content-Type' => 'image/jpeg'], '')
36
        );
37
    }
38
39
    /**
40
     * @covers VDB\Spider\Filter\Postfetch\MimeTypeFilter
41
     */
42
    public function testMimeTypeFilter()
43
    {
44
        $filter = new MimeTypeFilter('text/html');
45
        $this->assertTrue($filter->match($this->spiderResource));
46
47
        $filter = new MimeTypeFilter('image/jpeg');
48
        $this->assertFalse($filter->match($this->spiderResource));
49
50
    }
51
}
52