Completed
Push — master ( 02e675...86d051 )
by Matthijs
02:35
created

MimeTypeFilterTest::testMimeTypeFilter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6667
cc 1
eloc 5
nc 1
nop 0
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()
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::match()
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