Completed
Push — master ( 7de777...9be641 )
by
unknown
11:28
created

ImageProviderTest::testImage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 51
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 51
rs 9.4109
c 0
b 0
f 0
cc 1
eloc 28
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace MediaMonks\SonataMediaBundle\Tests\Functional;
4
5
class ImageProviderTest extends AdminTestAbstract
6
{
7
    public function testImage()
8
    {
9
        $provider = 'image';
10
11
        $crawler = $this->client->request('GET', self::BASE_PATH.'create?provider='.$provider);
12
13
        $form = $crawler->selectButton('Create')->form();
14
15
        $this->assertSonataFormValues(
16
            $form,
17
            [
18
                'provider' => $provider,
19
            ]
20
        );
21
22
        $this->setFormBinaryContent($form, $this->getFixturesPath().'monk.jpg');
23
24
        $crawler = $this->client->submit($form);
25
        $form = $crawler->selectButton('Update')->form();
26
27
        $this->assertSonataFormValues($form, ['title' => 'monk']);
28
29
        $this->client->request('GET', self::BASE_PATH.'list');
30
        $this->assertContains('monk', $this->client->getResponse()->getContent());
31
32
        $this->assertNumberOfFilesInPath(1, $this->getMediaPathPrivate());
33
34
        $this->verifyMediaImageIsGenerated();
35
36
        $crawler = $this->client->request('GET', '/twig');
37
38
        $this->assertEquals(
39
            4,
40
            $crawler->filter('img')->count()
41
        );
42
43
        $this->assertEquals(
44
            0,
45
            $crawler->filter('iframe')->count()
46
        );
47
48
        $this->assertEquals(
49
            1,
50
            $crawler->filter('a')->count()
51
        );
52
53
        $this->client->request('GET', '/api');
54
        $data = json_decode($this->client->getResponse()->getContent(), true);
55
56
        $this->assertArrayHasKey('url', $data);
57
    }
58
59 View Code Duplication
    public function testEmptyFileUpload()
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...
60
    {
61
        $provider = 'image';
62
63
        $crawler = $this->client->request('GET', self::BASE_PATH.'create?provider='.$provider);
64
65
        $form = $crawler->selectButton('Create')->form();
66
67
        $this->assertSonataFormValues(
68
            $form,
69
            [
70
                'provider' => $provider,
71
            ]
72
        );
73
74
        $this->client->submit($form);
75
76
        $this->assertContains('This value should not be blank', $this->client->getResponse()->getContent());
77
        $this->assertContains('This value should not be blank', $this->client->getResponse()->getContent());
78
    }
79
}
80