StaticSitemapServiceTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 79.07 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 34
loc 43
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testSitemap() 17 17 1
A testExecuteWIthNoUrl() 17 17 1
A createService() 0 4 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
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[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 Core23\SitemapBundle\Tests\Sitemap;
13
14
use Core23\SitemapBundle\Definition\SitemapDefinition;
15
use Core23\SitemapBundle\Model\Url;
16
use Core23\SitemapBundle\Sitemap\SitemapServiceInterface;
17
use Core23\SitemapBundle\Sitemap\StaticSitemapService;
18
use Core23\SitemapBundle\Test\AbstractSitemapServiceTestCase;
19
use Symfony\Component\OptionsResolver\OptionsResolver;
20
21
final class StaticSitemapServiceTest extends AbstractSitemapServiceTestCase
22
{
23 View Code Duplication
    public function testSitemap(): void
0 ignored issues
show
Duplication introduced by core23
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...
24
    {
25
        $sitemap = new SitemapDefinition('demo', [
26
            'priority'   => 20,
27
            'url'        => '/foo/bar',
28
            'changefreq' => Url::FREQUENCE_DAILY,
29
        ]);
30
31
        $optionResolver = new OptionsResolver();
32
        $this->service->configureSettings($optionResolver);
33
34
        $sitemap->setSettings($optionResolver->resolve($sitemap->getSettings()));
35
36
        $this->assertSitemap('/foo/bar', 20, Url::FREQUENCE_DAILY);
37
38
        $this->process($sitemap);
39
    }
40
41 View Code Duplication
    public function testExecuteWIthNoUrl(): void
0 ignored issues
show
Duplication introduced by core23
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...
42
    {
43
        $sitemap = new SitemapDefinition('demo', [
44
            'priority'   => 20,
45
            'url'        => null,
46
            'changefreq' => Url::FREQUENCE_DAILY,
47
        ]);
48
49
        $optionResolver = new OptionsResolver();
50
        $this->service->configureSettings($optionResolver);
51
52
        $sitemap->setSettings($optionResolver->resolve($sitemap->getSettings()));
53
54
        $this->assertSitemapCount(0);
55
56
        $this->process($sitemap);
57
    }
58
59
    protected function createService(): SitemapServiceInterface
60
    {
61
        return new StaticSitemapService();
62
    }
63
}
64