Completed
Push — master ( d9d4dc...0a1b8b )
by Michael
17:18 queued 06:39
created

InlineTest   A

Complexity

Total Complexity 34

Size/Duplication

Total Lines 466
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 466
rs 9.2
c 0
b 0
f 0
wmc 34
lcom 0
cbo 1

23 Methods

Rating   Name   Duplication   Size   Complexity  
A testParse() 0 4 1
A testParseWithMapObjects() 0 6 1
A testDump() 0 6 1
A testDumpNumericValueWithLocale() 0 21 4
A testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF() 0 6 1
A testParseScalarWithIncorrectlyQuotedStringShouldThrowException() 0 5 1
A testParseScalarWithIncorrectlyDoubleQuotedStringShouldThrowException() 0 5 1
A testParseInvalidMappingKeyShouldThrowException() 0 5 1
A testParseInvalidMappingShouldThrowException() 0 4 1
A testParseInvalidSequenceShouldThrowException() 0 4 1
A testParseScalarWithCorrectlyQuotedStringShouldReturnString() 0 7 1
A testParseReferences() 0 4 1
A getDataForParseReferences() 0 13 1
A testParseMapReferenceInSequence() 0 9 1
A testParseUnquotedAsterisk() 0 4 1
A testParseUnquotedAsteriskFollowedByAComment() 0 4 1
A getTestsForParse() 0 74 1
B getTestsForParseWithMapObjects() 0 78 1
A getTestsForDump() 0 56 1
A testNotSupportedMissingValue() 0 4 1
A testVeryLongQuotedStrings() 0 9 1
A testBooleanMappingKeysAreConvertedToStrings() 0 5 1
A testTheEmptyStringIsAValidMappingKey() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Symfony package.
5
 *
6
 * (c) Fabien Potencier <[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 Symfony\Component\Yaml\Tests;
13
14
use PHPUnit\Framework\TestCase;
15
use Symfony\Component\Yaml\Inline;
16
17
class InlineTest extends TestCase
18
{
19
    /**
20
     * @dataProvider getTestsForParse
21
     */
22
    public function testParse($yaml, $value)
23
    {
24
        $this->assertSame($value, Inline::parse($yaml), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml));
25
    }
26
27
    /**
28
     * @dataProvider getTestsForParseWithMapObjects
29
     */
30
    public function testParseWithMapObjects($yaml, $value)
31
    {
32
        $actual = Inline::parse($yaml, false, false, true);
33
34
        $this->assertSame(serialize($value), serialize($actual));
35
    }
36
37
    /**
38
     * @dataProvider getTestsForDump
39
     */
40
    public function testDump($yaml, $value)
41
    {
42
        $this->assertEquals($yaml, Inline::dump($value), sprintf('::dump() converts a PHP structure to an inline YAML (%s)', $yaml));
43
44
        $this->assertSame($value, Inline::parse(Inline::dump($value)), 'check consistency');
45
    }
46
47
    public function testDumpNumericValueWithLocale()
48
    {
49
        $locale = setlocale(LC_NUMERIC, 0);
50
        if (false === $locale) {
51
            $this->markTestSkipped('Your platform does not support locales.');
52
        }
53
54
        try {
55
            $requiredLocales = array('fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252');
56
            if (false === setlocale(LC_NUMERIC, $requiredLocales)) {
57
                $this->markTestSkipped('Could not set any of required locales: '.implode(', ', $requiredLocales));
58
            }
59
60
            $this->assertEquals('1.2', Inline::dump(1.2));
61
            $this->assertContains('fr', strtolower(setlocale(LC_NUMERIC, 0)));
62
            setlocale(LC_NUMERIC, $locale);
63
        } catch (\Exception $e) {
64
            setlocale(LC_NUMERIC, $locale);
65
            throw $e;
66
        }
67
    }
68
69
    public function testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF()
70
    {
71
        $value = '686e444';
72
73
        $this->assertSame($value, Inline::parse(Inline::dump($value)));
74
    }
75
76
    /**
77
     * @group legacy
78
     * throws \Symfony\Component\Yaml\Exception\ParseException in 3.0
79
     */
80
    public function testParseScalarWithNonEscapedBlackslashShouldThrowException()
81
    {
82
        $this->assertSame('Foo\Var', Inline::parse('"Foo\Var"'));
83
    }
84
85
    /**
86
     * @expectedException \Symfony\Component\Yaml\Exception\ParseException
87
     */
88
    public function testParseScalarWithNonEscapedBlackslashAtTheEndShouldThrowException()
89
    {
90
        Inline::parse('"Foo\\"');
91
    }
92
93
    /**
94
     * @expectedException \Symfony\Component\Yaml\Exception\ParseException
95
     */
96
    public function testParseScalarWithIncorrectlyQuotedStringShouldThrowException()
97
    {
98
        $value = "'don't do somthin' like that'";
99
        Inline::parse($value);
100
    }
101
102
    /**
103
     * @expectedException \Symfony\Component\Yaml\Exception\ParseException
104
     */
105
    public function testParseScalarWithIncorrectlyDoubleQuotedStringShouldThrowException()
106
    {
107
        $value = '"don"t do somthin" like that"';
108
        Inline::parse($value);
109
    }
110
111
    /**
112
     * @expectedException \Symfony\Component\Yaml\Exception\ParseException
113
     */
114
    public function testParseInvalidMappingKeyShouldThrowException()
115
    {
116
        $value = '{ "foo " bar": "bar" }';
117
        Inline::parse($value);
118
    }
119
120
    /**
121
     * @expectedException \Symfony\Component\Yaml\Exception\ParseException
122
     */
123
    public function testParseInvalidMappingShouldThrowException()
124
    {
125
        Inline::parse('[foo] bar');
126
    }
127
128
    /**
129
     * @expectedException \Symfony\Component\Yaml\Exception\ParseException
130
     */
131
    public function testParseInvalidSequenceShouldThrowException()
132
    {
133
        Inline::parse('{ foo: bar } bar');
134
    }
135
136
    public function testParseScalarWithCorrectlyQuotedStringShouldReturnString()
137
    {
138
        $value = "'don''t do somthin'' like that'";
139
        $expect = "don't do somthin' like that";
140
141
        $this->assertSame($expect, Inline::parseScalar($value));
142
    }
143
144
    /**
145
     * @dataProvider getDataForParseReferences
146
     */
147
    public function testParseReferences($yaml, $expected)
148
    {
149
        $this->assertSame($expected, Inline::parse($yaml, false, false, false, array('var' => 'var-value')));
150
    }
151
152
    public function getDataForParseReferences()
153
    {
154
        return array(
155
            'scalar' => array('*var', 'var-value'),
156
            'list' => array('[ *var ]', array('var-value')),
157
            'list-in-list' => array('[[ *var ]]', array(array('var-value'))),
158
            'map-in-list' => array('[ { key: *var } ]', array(array('key' => 'var-value'))),
159
            'embedded-mapping-in-list' => array('[ key: *var ]', array(array('key' => 'var-value'))),
160
            'map' => array('{ key: *var }', array('key' => 'var-value')),
161
            'list-in-map' => array('{ key: [*var] }', array('key' => array('var-value'))),
162
            'map-in-map' => array('{ foo: { bar: *var } }', array('foo' => array('bar' => 'var-value'))),
163
        );
164
    }
165
166
    public function testParseMapReferenceInSequence()
167
    {
168
        $foo = array(
169
            'a' => 'Steve',
170
            'b' => 'Clark',
171
            'c' => 'Brian',
172
        );
173
        $this->assertSame(array($foo), Inline::parse('[*foo]', false, false, false, array('foo' => $foo)));
174
    }
175
176
    /**
177
     * @expectedException \Symfony\Component\Yaml\Exception\ParseException
178
     * @expectedExceptionMessage A reference must contain at least one character.
179
     */
180
    public function testParseUnquotedAsterisk()
181
    {
182
        Inline::parse('{ foo: * }');
183
    }
184
185
    /**
186
     * @expectedException \Symfony\Component\Yaml\Exception\ParseException
187
     * @expectedExceptionMessage A reference must contain at least one character.
188
     */
189
    public function testParseUnquotedAsteriskFollowedByAComment()
190
    {
191
        Inline::parse('{ foo: * #foo }');
192
    }
193
194
    /**
195
     * @group legacy
196
     * @dataProvider getReservedIndicators
197
     * throws \Symfony\Component\Yaml\Exception\ParseException in 3.0
198
     */
199
    public function testParseUnquotedScalarStartingWithReservedIndicator($indicator)
200
    {
201
        Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
202
    }
203
204
    public function getReservedIndicators()
205
    {
206
        return array(array('@'), array('`'));
207
    }
208
209
    /**
210
     * @group legacy
211
     * @dataProvider getScalarIndicators
212
     * throws \Symfony\Component\Yaml\Exception\ParseException in 3.0
213
     */
214
    public function testParseUnquotedScalarStartingWithScalarIndicator($indicator)
215
    {
216
        Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
217
    }
218
219
    public function getScalarIndicators()
220
    {
221
        return array(array('|'), array('>'));
222
    }
223
224
    /**
225
     * @dataProvider getDataForIsHash
226
     */
227
    public function testIsHash($array, $expected)
228
    {
229
        $this->assertSame($expected, Inline::isHash($array));
230
    }
231
232
    public function getDataForIsHash()
233
    {
234
        return array(
235
            array(array(), false),
236
            array(array(1, 2, 3), false),
237
            array(array(2 => 1, 1 => 2, 0 => 3), true),
238
            array(array('foo' => 1, 'bar' => 2), true),
239
        );
240
    }
241
242
    public function getTestsForParse()
243
    {
244
        return array(
245
            array('', ''),
246
            array('null', null),
247
            array('false', false),
248
            array('true', true),
249
            array('12', 12),
250
            array('-12', -12),
251
            array('"quoted string"', 'quoted string'),
252
            array("'quoted string'", 'quoted string'),
253
            array('12.30e+02', 12.30e+02),
254
            array('0x4D2', 0x4D2),
255
            array('02333', 02333),
256
            array('.Inf', -log(0)),
257
            array('-.Inf', log(0)),
258
            array("'686e444'", '686e444'),
259
            array('686e444', 646e444),
260
            array('123456789123456789123456789123456789', '123456789123456789123456789123456789'),
261
            array('"foo\r\nbar"', "foo\r\nbar"),
262
            array("'foo#bar'", 'foo#bar'),
263
            array("'foo # bar'", 'foo # bar'),
264
            array("'#cfcfcf'", '#cfcfcf'),
265
            array('::form_base.html.twig', '::form_base.html.twig'),
266
267
            // Pre-YAML-1.2 booleans
268
            array("'y'", 'y'),
269
            array("'n'", 'n'),
270
            array("'yes'", 'yes'),
271
            array("'no'", 'no'),
272
            array("'on'", 'on'),
273
            array("'off'", 'off'),
274
275
            array('2007-10-30', gmmktime(0, 0, 0, 10, 30, 2007)),
276
            array('2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)),
277
            array('2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)),
278
            array('1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)),
279
            array('1730-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 1730)),
280
281
            array('"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''),
282
            array("'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''),
283
284
            // sequences
285
            // urls are no key value mapping. see #3609. Valid yaml "key: value" mappings require a space after the colon
286
            array('[foo, http://urls.are/no/mappings, false, null, 12]', array('foo', 'http://urls.are/no/mappings', false, null, 12)),
287
            array('[  foo  ,   bar , false  ,  null     ,  12  ]', array('foo', 'bar', false, null, 12)),
288
            array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')),
289
290
            // mappings
291
            array('{foo:bar,bar:foo,false:false,null:null,integer:12}', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
292
            array('{ foo  : bar, bar : foo,  false  :   false,  null  :   null,  integer :  12  }', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
293
            array('{foo: \'bar\', bar: \'foo: bar\'}', array('foo' => 'bar', 'bar' => 'foo: bar')),
294
            array('{\'foo\': \'bar\', "bar": \'foo: bar\'}', array('foo' => 'bar', 'bar' => 'foo: bar')),
295
            array('{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}', array('foo\'' => 'bar', 'bar"' => 'foo: bar')),
296
            array('{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}', array('foo: ' => 'bar', 'bar: ' => 'foo: bar')),
297
298
            // nested sequences and mappings
299
            array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))),
300
            array('[foo, {bar: foo}]', array('foo', array('bar' => 'foo'))),
301
            array('{ foo: {bar: foo} }', array('foo' => array('bar' => 'foo'))),
302
            array('{ foo: [bar, foo] }', array('foo' => array('bar', 'foo'))),
303
304
            array('[  foo, [  bar, foo  ]  ]', array('foo', array('bar', 'foo'))),
305
306
            array('[{ foo: {bar: foo} }]', array(array('foo' => array('bar' => 'foo')))),
307
308
            array('[foo, [bar, [foo, [bar, foo]], foo]]', array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo'))),
309
310
            array('[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]', array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo')))),
311
312
            array('[foo, bar: { foo: bar }]', array('foo', '1' => array('bar' => array('foo' => 'bar')))),
313
            array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')),
314
        );
315
    }
316
317
    public function getTestsForParseWithMapObjects()
318
    {
319
        return array(
320
            array('', ''),
321
            array('null', null),
322
            array('false', false),
323
            array('true', true),
324
            array('12', 12),
325
            array('-12', -12),
326
            array('"quoted string"', 'quoted string'),
327
            array("'quoted string'", 'quoted string'),
328
            array('12.30e+02', 12.30e+02),
329
            array('0x4D2', 0x4D2),
330
            array('02333', 02333),
331
            array('.Inf', -log(0)),
332
            array('-.Inf', log(0)),
333
            array("'686e444'", '686e444'),
334
            array('686e444', 646e444),
335
            array('123456789123456789123456789123456789', '123456789123456789123456789123456789'),
336
            array('"foo\r\nbar"', "foo\r\nbar"),
337
            array("'foo#bar'", 'foo#bar'),
338
            array("'foo # bar'", 'foo # bar'),
339
            array("'#cfcfcf'", '#cfcfcf'),
340
            array('::form_base.html.twig', '::form_base.html.twig'),
341
342
            array('2007-10-30', gmmktime(0, 0, 0, 10, 30, 2007)),
343
            array('2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)),
344
            array('2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)),
345
            array('1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)),
346
            array('1730-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 1730)),
347
348
            array('"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''),
349
            array("'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''),
350
351
            // sequences
352
            // urls are no key value mapping. see #3609. Valid yaml "key: value" mappings require a space after the colon
353
            array('[foo, http://urls.are/no/mappings, false, null, 12]', array('foo', 'http://urls.are/no/mappings', false, null, 12)),
354
            array('[  foo  ,   bar , false  ,  null     ,  12  ]', array('foo', 'bar', false, null, 12)),
355
            array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')),
356
357
            // mappings
358
            array('{foo:bar,bar:foo,false:false,null:null,integer:12}', (object) array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
359
            array('{ foo  : bar, bar : foo,  false  :   false,  null  :   null,  integer :  12  }', (object) array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
360
            array('{foo: \'bar\', bar: \'foo: bar\'}', (object) array('foo' => 'bar', 'bar' => 'foo: bar')),
361
            array('{\'foo\': \'bar\', "bar": \'foo: bar\'}', (object) array('foo' => 'bar', 'bar' => 'foo: bar')),
362
            array('{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}', (object) array('foo\'' => 'bar', 'bar"' => 'foo: bar')),
363
            array('{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}', (object) array('foo: ' => 'bar', 'bar: ' => 'foo: bar')),
364
365
            // nested sequences and mappings
366
            array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))),
367
            array('[foo, {bar: foo}]', array('foo', (object) array('bar' => 'foo'))),
368
            array('{ foo: {bar: foo} }', (object) array('foo' => (object) array('bar' => 'foo'))),
369
            array('{ foo: [bar, foo] }', (object) array('foo' => array('bar', 'foo'))),
370
371
            array('[  foo, [  bar, foo  ]  ]', array('foo', array('bar', 'foo'))),
372
373
            array('[{ foo: {bar: foo} }]', array((object) array('foo' => (object) array('bar' => 'foo')))),
374
375
            array('[foo, [bar, [foo, [bar, foo]], foo]]', array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo'))),
376
377
            array('[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]', array('foo', (object) array('bar' => 'foo', 'foo' => array('foo', (object) array('bar' => 'foo'))), array('foo', (object) array('bar' => 'foo')))),
378
379
            array('[foo, bar: { foo: bar }]', array('foo', '1' => (object) array('bar' => (object) array('foo' => 'bar')))),
380
            array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', (object) array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')),
381
382
            array('{}', new \stdClass()),
383
            array('{ foo  : bar, bar : {}  }', (object) array('foo' => 'bar', 'bar' => new \stdClass())),
384
            array('{ foo  : [], bar : {}  }', (object) array('foo' => array(), 'bar' => new \stdClass())),
385
            array('{foo: \'bar\', bar: {} }', (object) array('foo' => 'bar', 'bar' => new \stdClass())),
386
            array('{\'foo\': \'bar\', "bar": {}}', (object) array('foo' => 'bar', 'bar' => new \stdClass())),
387
            array('{\'foo\': \'bar\', "bar": \'{}\'}', (object) array('foo' => 'bar', 'bar' => '{}')),
388
389
            array('[foo, [{}, {}]]', array('foo', array(new \stdClass(), new \stdClass()))),
390
            array('[foo, [[], {}]]', array('foo', array(array(), new \stdClass()))),
391
            array('[foo, [[{}, {}], {}]]', array('foo', array(array(new \stdClass(), new \stdClass()), new \stdClass()))),
392
            array('[foo, {bar: {}}]', array('foo', '1' => (object) array('bar' => new \stdClass()))),
393
        );
394
    }
395
396
    public function getTestsForDump()
397
    {
398
        return array(
399
            array('null', null),
400
            array('false', false),
401
            array('true', true),
402
            array('12', 12),
403
            array("'quoted string'", 'quoted string'),
404
            array('!!float 1230', 12.30e+02),
405
            array('1234', 0x4D2),
406
            array('1243', 02333),
407
            array('.Inf', -log(0)),
408
            array('-.Inf', log(0)),
409
            array("'686e444'", '686e444'),
410
            array('"foo\r\nbar"', "foo\r\nbar"),
411
            array("'foo#bar'", 'foo#bar'),
412
            array("'foo # bar'", 'foo # bar'),
413
            array("'#cfcfcf'", '#cfcfcf'),
414
415
            array("'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''),
416
417
            array("'-dash'", '-dash'),
418
            array("'-'", '-'),
419
420
            // Pre-YAML-1.2 booleans
421
            array("'y'", 'y'),
422
            array("'n'", 'n'),
423
            array("'yes'", 'yes'),
424
            array("'no'", 'no'),
425
            array("'on'", 'on'),
426
            array("'off'", 'off'),
427
428
            // sequences
429
            array('[foo, bar, false, null, 12]', array('foo', 'bar', false, null, 12)),
430
            array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')),
431
432
            // mappings
433
            array('{ foo: bar, bar: foo, \'false\': false, \'null\': null, integer: 12 }', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
434
            array('{ foo: bar, bar: \'foo: bar\' }', array('foo' => 'bar', 'bar' => 'foo: bar')),
435
436
            // nested sequences and mappings
437
            array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))),
438
439
            array('[foo, [bar, [foo, [bar, foo]], foo]]', array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo'))),
440
441
            array('{ foo: { bar: foo } }', array('foo' => array('bar' => 'foo'))),
442
443
            array('[foo, { bar: foo }]', array('foo', array('bar' => 'foo'))),
444
445
            array('[foo, { bar: foo, foo: [foo, { bar: foo }] }, [foo, { bar: foo }]]', array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo')))),
446
447
            array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')),
448
449
            array('{ foo: { bar: { 1: 2, baz: 3 } } }', array('foo' => array('bar' => array(1 => 2, 'baz' => 3)))),
450
        );
451
    }
452
453
    /**
454
     * @expectedException \Symfony\Component\Yaml\Exception\ParseException
455
     * @expectedExceptionMessage Malformed inline YAML string: {this, is not, supported}.
456
     */
457
    public function testNotSupportedMissingValue()
458
    {
459
        Inline::parse('{this, is not, supported}');
460
    }
461
462
    public function testVeryLongQuotedStrings()
463
    {
464
        $longStringWithQuotes = str_repeat("x\r\n\\\"x\"x", 1000);
465
466
        $yamlString = Inline::dump(array('longStringWithQuotes' => $longStringWithQuotes));
467
        $arrayFromYaml = Inline::parse($yamlString);
468
469
        $this->assertEquals($longStringWithQuotes, $arrayFromYaml['longStringWithQuotes']);
470
    }
471
472
    public function testBooleanMappingKeysAreConvertedToStrings()
473
    {
474
        $this->assertSame(array('false' => 'foo'), Inline::parse('{false: foo}'));
475
        $this->assertSame(array('true' => 'foo'), Inline::parse('{true: foo}'));
476
    }
477
478
    public function testTheEmptyStringIsAValidMappingKey()
479
    {
480
        $this->assertSame(array('' => 'foo'), Inline::parse('{ "": foo }'));
481
    }
482
}
483