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.
Test Failed
Push — master ( 6a0f46...ee4e74 )
by Matthias
03:03
created

EmbeddedShortcodeHandlerTest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 59
rs 10
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A processShortcodes() 0 9 2
A provideEsiShortcodes() 0 4 1
A processing_with_esi_fragments() 0 6 1
A paragraphs_wrapping_shortcodes_get_removed() 0 3 1
A content_without_shortcodes_wont_be_changed() 0 3 1
A provideShortcodeNames() 0 6 1
A expand_shortcodes_registered_in_different_ways() 0 4 1
1
<?php
2
3
namespace Webfactory\ShortcodeBundle\Tests\Functional;
4
5
use Generator;
6
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\HttpFoundation\RequestStack;
9
use Webfactory\ShortcodeBundle\Test\EndToEndTestHelper;
10
11
/**
12
 * Test shortcode processing using EmbeddedShortcodeHandler and a fixture ShortodeTestController,
13
 * to make sure shortcodes defined in various places (DI config, bundle config) work as expected.
14
 */
15
class EmbeddedShortcodeHandlerTest extends KernelTestCase
16
{
17
    /** @test */
18
    public function paragraphs_wrapping_shortcodes_get_removed(): void
19
    {
20
        self::assertSame('test', $this->processShortcodes('<p>[test-config-inline]</p>'));
21
    }
22
23
    /** @test */
24
    public function content_without_shortcodes_wont_be_changed(): void
25
    {
26
        self::assertSame('<p>Content without shortcode</p>', $this->processShortcodes('<p>Content without shortcode</p>'));
27
    }
28
29
    /**
30
     * @test
31
     * @dataProvider provideShortcodeNames
32
     */
33
    public function expand_shortcodes_registered_in_different_ways(string $shortcodeName): void
34
    {
35
        // All shortcodes are set up as fixtures and use ShortcodeTestController
36
        self::assertSame('test foo=bar', $this->processShortcodes("[$shortcodeName foo=bar]"));
37
    }
38
39
    public function provideShortcodeNames(): Generator
40
    {
41
        yield 'Inline shortcode defined in bundle config' => ['test-config-inline'];
42
        yield 'ESI-based shortcode defined in bundle config' => ['test-config-esi'];
43
        yield 'Inline shortcode defined in service definitions' => ['test-service-inline'];
44
        yield 'ESI-based shortcode defined in service definitions' => ['test-service-esi'];
45
    }
46
47
    /**
48
     * @test
49
     * @dataProvider provideEsiShortcodes
50
     */
51
    public function processing_with_esi_fragments(string $shortcodeName): void
52
    {
53
        $request = new Request([], [], [], [], [], ['SCRIPT_URL' => '/', 'HTTP_HOST' => 'localhost']);
54
        $request->headers->set('Surrogate-Capability', 'ESI/1.0');
55
56
        self::assertStringContainsString('<esi:include ', $this->processShortcodes("[$shortcodeName foo=bar]", $request));
57
    }
58
59
    public function provideEsiShortcodes(): Generator
60
    {
61
        yield 'ESI-based shortcode defined in bundle configuration' => ['test-config-esi'];
62
        yield 'ESI-based shortcode defined in service configuration' => ['test-service-esi'];
63
    }
64
65
    private function processShortcodes(string $content, Request $request = null): string
66
    {
67
        self::bootKernel();
68
69
        if ($request) {
70
            static::$container->get(RequestStack::class)->push($request);
71
        }
72
73
        return EndToEndTestHelper::createFromContainer(static::$container)->processShortcode($content);
74
    }
75
}
76