GalleryImageShortCodeHandlerTest::testValidImage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 9

Duplication

Lines 19
Ratio 100 %
Metric Value
dl 19
loc 19
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
class GalleryImageShortCodeHandlerTest extends SapphireTest {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
  protected static $fixture_file = 'ss3gallery/tests/ss3gallery.yml';
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 2
Loading history...
5
6 View Code Duplication
    public function testValidImage()
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...
7
    {
8
        $page = $this->objFromFixture('Page', 'page02');
9
10
        $galleryImage = $this->objFromFixture('GalleryImage', 'gi01');
11
        $content = "[GalleryImage id='{$galleryImage->ID}']";
12
        $page->Content = $content;
13
        $page->write();
14
        $html = ShortcodeParser::get_active()->parse($page->Content);
15
16
        $this->assertEquals('<div class="imageWithCaption centercontents ">
17
<img src=""><div class="meta">
18
    <p class="exif">f s </p>
19
    <p class="caption">Test Image 1</p>
20
</div>
21
</div>
22
23
', $html);
24
  }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 2
Loading history...
Coding Style introduced by
Closing brace indented incorrectly; expected 4 spaces, found 2
Loading history...
25
26
27 View Code Duplication
    public function testNonExistentImage()
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...
28
    {
29
        $page = $this->objFromFixture('Page', 'page02');
30
31
        $galleryImage = $this->objFromFixture('GalleryImage', 'gi01');
32
        $nonExistentID = 1000+$galleryImage->ID;
33
        // his will not exist
34
        $content = "[GalleryImage id='{$nonExistentID}']";
35
        $page->Content = $content;
36
        $page->write();
37
        $html = ShortcodeParser::get_active()->parse($page->Content);
38
39
        $this->assertEquals('image not found', $html);
40
    }
41
}
42