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 ( 5265cb...c87b3e )
by Tomasz
02:12
created

testInvalidSerializationFormatException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
namespace Thunder\Shortcode\Tests;
3
4
use Thunder\Shortcode\EventHandler\FilterRawEventHandler;
5
use Thunder\Shortcode\Events;
6
use Thunder\Shortcode\HandlerContainer\HandlerContainer;
7
use Thunder\Shortcode\Parser\RegexParser;
8
use Thunder\Shortcode\Shortcode\Shortcode;
9
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
10
use Thunder\Shortcode\ShortcodeFacade;
11
use Thunder\Shortcode\Syntax\CommonSyntax;
12
13
/**
14
 * @author Tomasz Kowalczyk <[email protected]>
15
 */
16
final class FacadeTest extends \PHPUnit_Framework_TestCase
17
{
18
    public function testFacade()
19
    {
20
        $handlers = new HandlerContainer();
21
        $handlers
22
            ->add('name', function (ShortcodeInterface $s) { return $s->getName(); })
23
            ->addAlias('n', 'name');
24
25
        $facade = ShortcodeFacade::create($handlers, new CommonSyntax());
0 ignored issues
show
Deprecated Code introduced by
The method Thunder\Shortcode\ShortcodeFacade::create() has been deprecated with message: use constructor and customize using exposed methods

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
26
        $facade->addHandler('content', function (ShortcodeInterface $s) { return $s->getContent(); });
27
        $facade->addHandlerAlias('c', 'content');
28
        $facade->setParser(new RegexParser());
29
30
        $this->assertSame('n', $facade->process('[n]'));
31
        $this->assertSame('c', $facade->process('[c]c[/c]'));
32
33
        $shortcodes = $facade->parse('[b]');
34
        $this->assertInstanceOf('Thunder\\Shortcode\\Shortcode\\ParsedShortcodeInterface', $shortcodes[0]);
35
    }
36
37
    public function testFacadeEvents()
38
    {
39
        $facade = new ShortcodeFacade();
40
        $facade->addHandler('n', function (ShortcodeInterface $s) { return $s->getName(); });
41
        $facade->addEventHandler(Events::FILTER_SHORTCODES, new FilterRawEventHandler(array('raw')));
42
43
        $this->assertSame('[raw] [n] [/raw]', $facade->process('[raw] [n] [/raw]'));
44
    }
45
46
    public function testSerialization()
47
    {
48
        $facade = new ShortcodeFacade();
49
50
        $s = new Shortcode('c', array(), null);
51
        $this->assertSame('[c /]', $facade->serializeToText($s));
0 ignored issues
show
Deprecated Code introduced by
The method Thunder\Shortcode\Shortc...cade::serializeToText() has been deprecated with message: use serialize($shortcode, $format)

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
52
        $this->assertSame('c', $facade->unserializeFromText('[c]')->getName());
0 ignored issues
show
Deprecated Code introduced by
The method Thunder\Shortcode\Shortc...::unserializeFromText() has been deprecated with message: use unserialize($shortcode, $format)

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
53
        $this->assertSame('[c /]', $facade->serialize($s, 'text'));
54
        $this->assertSame('c', $facade->unserialize('[c]', 'text')->getName());
55
56
        $json = '{"name":"c","parameters":[],"content":null,"bbCode":null}';
57
        $this->assertSame($json, $facade->serializeToJson($s));
0 ignored issues
show
Deprecated Code introduced by
The method Thunder\Shortcode\Shortc...cade::serializeToJson() has been deprecated with message: use serialize($shortcode, $format)

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
58
        $this->assertSame('c', $facade->unserializeFromJson($json)->getName());
0 ignored issues
show
Deprecated Code introduced by
The method Thunder\Shortcode\Shortc...::unserializeFromJson() has been deprecated with message: use unserialize($shortcode, $format)

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
59
        $this->assertSame($json, $facade->serialize($s, 'json'));
60
        $this->assertSame('c', $facade->unserialize($json, 'json')->getName());
61
62
        $yaml = <<<EOF
63
name: c
64
parameters: {  }
65
content: null
66
bbCode: null
67
68
EOF;
69
        $this->assertSame($yaml, $facade->serialize($s, 'yaml'));
70
        $this->assertSame('c', $facade->unserialize($yaml, 'yaml')->getName());
71
72
        $xml = <<<EOF
73
<?xml version="1.0" encoding="UTF-8"?>
74
<shortcode name="c">
75
  <bbCode/>
76
  <parameters/>
77
  <content/>
78
</shortcode>
79
80
EOF;
81
        $this->assertSame($xml, $facade->serialize($s, 'xml'));
82
        $this->assertSame('c', $facade->unserialize($xml, 'xml')->getName());
83
    }
84
85
    public function testInvalidSerializationFormatException()
86
    {
87
        $this->setExpectedException('InvalidArgumentException');
88
        $facade = new ShortcodeFacade();
89
        $facade->serialize(new Shortcode('name', array(), null), 'invalid');
90
    }
91
92
    public function testInvalidUnserializationFormatException()
93
    {
94
        $this->setExpectedException('InvalidArgumentException');
95
        $facade = new ShortcodeFacade();
96
        $facade->unserialize('[c]', 'invalid');
97
    }
98
}
99