GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 6c5077...d22a37 )
by Christian
01:33
created

SitemapCompilerPassTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 103
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 6
dl 0
loc 103
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 15 1
A testProcess() 0 25 2
A testProcessWithNoServices() 0 9 1
A testProcessWithStaticUrls() 0 28 1
A testProcessWithEmptyGroups() 0 10 1
1
<?php
2
3
/*
4
 * (c) Christian Gripp <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Core23\SitemapBundle\Tests\DependencyInjection\Compiler;
11
12
use Core23\SitemapBundle\Definition\DefintionManagerInterface;
13
use Core23\SitemapBundle\DependencyInjection\Compiler\SitemapCompilerPass;
14
use Core23\SitemapBundle\Sitemap\SitemapServiceManagerInterface;
15
use Core23\SitemapBundle\Sitemap\StaticSitemapService;
16
use PHPUnit\Framework\TestCase;
17
use Prophecy\Argument;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
use Symfony\Component\DependencyInjection\Definition;
20
use Symfony\Component\DependencyInjection\Reference;
21
22
class SitemapCompilerPassTest extends TestCase
23
{
24
    private $serviceManager;
25
26
    private $definitionManager;
27
28
    /**
29
     * @var ContainerBuilder
30
     */
31
    private $container;
32
33
    protected function setUp()
34
    {
35
        $this->serviceManager = $this->prophesize(Definition::class);
36
        $this->serviceManager->hasTag('core23.sitemap')
37
            ->willReturn(false)
38
        ;
39
        $this->definitionManager = $this->prophesize(Definition::class);
40
        $this->definitionManager->hasTag('core23.sitemap')
41
            ->willReturn(false)
42
        ;
43
44
        $this->container = new ContainerBuilder();
45
        $this->container->setDefinition(SitemapServiceManagerInterface::class, $this->serviceManager->reveal());
46
        $this->container->setDefinition(DefintionManagerInterface::class, $this->definitionManager->reveal());
47
    }
48
49
    public function testProcess(): void
50
    {
51
        $this->serviceManager->addMethodCall('addSitemap', Argument::that(function ($args) {
52
            return 'acme.sitemap' === $args[0] && $args[1] instanceof Reference;
53
        }))
54
        ->shouldBeCalled()
55
        ;
56
57
        $this->definitionManager->addMethodCall('addDefinition', [
58
            'acme.sitemap',
59
        ])
60
        ->shouldBeCalled()
61
        ;
62
63
        $sitemapDefinition = new Definition();
64
        $sitemapDefinition->addTag('core23.sitemap');
65
66
        $this->container->setParameter('core23_sitemap.static_urls', []);
67
        $this->container->setDefinition('acme.sitemap', $sitemapDefinition);
68
69
        $compiler = new SitemapCompilerPass();
70
        $compiler->process($this->container);
71
72
        $this->assertTrue($sitemapDefinition->isPublic());
73
    }
74
75
    public function testProcessWithNoServices(): void
76
    {
77
        $this->container->setParameter('core23_sitemap.static_urls', []);
78
79
        $compiler = new SitemapCompilerPass();
80
        $compiler->process($this->container);
81
82
        $this->assertTrue(true);
83
    }
84
85
    public function testProcessWithStaticUrls(): void
86
    {
87
        $this->definitionManager->addMethodCall('addDefinition', [
88
            StaticSitemapService::class,
89
            [
90
                [
91
                    'url'        => 'http://example.com',
92
                    'priority'   => 100,
93
                    'changefreq' => 'daily',
94
                ],
95
            ],
96
        ])
97
            ->shouldBeCalled()
98
        ;
99
100
        $this->container->setParameter('core23_sitemap.static_urls', [
101
            'static' => [
102
                [
103
                    'url'        => 'http://example.com',
104
                    'priority'   => 100,
105
                    'changefreq' => 'daily',
106
                ],
107
            ],
108
        ]);
109
110
        $compiler = new SitemapCompilerPass();
111
        $compiler->process($this->container);
112
    }
113
114
    public function testProcessWithEmptyGroups(): void
115
    {
116
        $this->container->setParameter('core23_sitemap.static_urls', []);
117
118
        $compiler = new SitemapCompilerPass();
119
        $compiler->process($this->container);
120
121
        $this->serviceManager->addMethodCall(Argument::any())->shouldNotBeCalled();
122
        $this->definitionManager->addMethodCall(Argument::any())->shouldNotBeCalled();
123
    }
124
}
125