Completed
Push — master ( 665782...a8382c )
by Matthijs
04:42 queued 02:50
created

Tests/Filter/Postfetch/MimeTypeFilterTest.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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 View Code Duplication
    protected function setUp()
0 ignored issues
show
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