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.

EmbeddedShortcodeHandlerTest::processShortcodes()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 9
rs 10
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
     *
32
     * @dataProvider provideShortcodeNames
33
     */
34
    public function expand_shortcodes_registered_in_different_ways(string $shortcodeName): void
35
    {
36
        // All shortcodes are set up as fixtures and use ShortcodeTestController
37
        self::assertSame('test foo=bar', $this->processShortcodes("[$shortcodeName foo=bar]"));
38
    }
39
40
    public static function provideShortcodeNames(): Generator
41
    {
42
        yield 'Inline shortcode defined in bundle config' => ['test-config-inline'];
43
        yield 'ESI-based shortcode defined in bundle config' => ['test-config-esi'];
44
        yield 'Inline shortcode defined in service definitions' => ['test-service-inline'];
45
        yield 'ESI-based shortcode defined in service definitions' => ['test-service-esi'];
46
    }
47
48
    /**
49
     * @test
50
     *
51
     * @dataProvider provideEsiShortcodes
52
     */
53
    public function processing_with_esi_fragments(string $shortcodeName): void
54
    {
55
        $request = new Request([], [], [], [], [], ['SCRIPT_URL' => '/', 'HTTP_HOST' => 'localhost']);
56
        $request->headers->set('Surrogate-Capability', 'ESI/1.0');
57
58
        self::assertStringContainsString('<esi:include ', $this->processShortcodes("[$shortcodeName foo=bar]", $request));
59
    }
60
61
    public static function provideEsiShortcodes(): Generator
62
    {
63
        yield 'ESI-based shortcode defined in bundle configuration' => ['test-config-esi'];
64
        yield 'ESI-based shortcode defined in service configuration' => ['test-service-esi'];
65
    }
66
67
    private function processShortcodes(string $content, ?Request $request = null): string
68
    {
69
        self::bootKernel();
70
71
        if ($request) {
72
            static::getContainer()->get(RequestStack::class)->push($request);
73
        }
74
75
        return EndToEndTestHelper::createFromContainer(static::getContainer())->processShortcode($content);
76
    }
77
}
78