GalleryImageShortCodeHandlerTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 84.62 %

Coupling/Cohesion

Components 0
Dependencies 3
Metric Value
wmc 2
lcom 0
cbo 3
dl 33
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testValidImage() 19 19 1
A testNonExistentImage() 14 14 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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