Completed
Push — 2.2 ( 8a877d )
by Damian
09:45 queued 06:58
created

BlogPostFilterTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 48.65 %

Coupling/Cohesion

Components 0
Dependencies 3
Metric Value
wmc 4
lcom 0
cbo 3
dl 18
loc 37
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A tearDown() 0 5 1
A testFilter() 18 18 2

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
/**
4
 * @mixin PHPUnit_Framework_TestCase
5
 */
6
class BlogPostFilterTest 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...
7
	/**
8
	 * @var string
9
	 */
10
	static $fixture_file = 'blog.yml';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $fixture_file.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
11
12
	public function setUp() {
13
		parent::setUp();
14
15
		SS_Datetime::set_mock_now('2013-10-10 20:00:00');
16
	}
17
18
	public function tearDown() {
19
		SS_Datetime::clear_mock_now();
20
21
		parent::tearDown();
22
	}
23
24 View Code Duplication
	public function testFilter() {
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...
25
		$member = Member::currentUser();
26
27
		if($member) {
28
			$member->logout();
29
		}
30
31
		/**
32
		 * @var Blog $blog
33
		 */
34
		$blog = $this->objFromFixture('Blog', 'FirstBlog');
35
36
		$this->assertEquals(3, $blog->AllChildren()->Count(), 'Filtered blog posts');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogPostFilterTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
38
		SS_Datetime::set_mock_now('2020-01-01 00:00:00');
39
40
		$this->assertEquals(5, $blog->AllChildren()->Count(), 'Unfiltered blog posts');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogPostFilterTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
	}
42
}
43