|
14 | 14 | use PHPUnit\Framework\TestCase;
|
15 | 15 | use Symfony\Component\Yaml\Exception\ParseException;
|
16 | 16 | use Symfony\Component\Yaml\Inline;
|
| 17 | +use Symfony\Component\Yaml\Tag\TaggedValue; |
17 | 18 | use Symfony\Component\Yaml\Yaml;
|
18 | 19 |
|
19 | 20 | class InlineTest extends TestCase
|
@@ -695,4 +696,40 @@ public function getNotPhpCompatibleMappingKeyData()
|
695 | 696 | 'float' => array('{0.25: "foo"}', array('0.25' => 'foo')),
|
696 | 697 | );
|
697 | 698 | }
|
| 699 | + |
| 700 | + public function testTagWithoutValueInSequence() |
| 701 | + { |
| 702 | + $value = Inline::parse('[!foo]', Yaml::PARSE_CUSTOM_TAGS); |
| 703 | + |
| 704 | + $this->assertInstanceOf(TaggedValue::class, $value[0]); |
| 705 | + $this->assertSame('foo', $value[0]->getTag()); |
| 706 | + $this->assertSame('', $value[0]->getValue()); |
| 707 | + } |
| 708 | + |
| 709 | + public function testTagWithEmptyValueInSequence() |
| 710 | + { |
| 711 | + $value = Inline::parse('[!foo ""]', Yaml::PARSE_CUSTOM_TAGS); |
| 712 | + |
| 713 | + $this->assertInstanceOf(TaggedValue::class, $value[0]); |
| 714 | + $this->assertSame('foo', $value[0]->getTag()); |
| 715 | + $this->assertSame('', $value[0]->getValue()); |
| 716 | + } |
| 717 | + |
| 718 | + public function testTagWithoutValueInMapping() |
| 719 | + { |
| 720 | + $value = Inline::parse('{foo: !bar}', Yaml::PARSE_CUSTOM_TAGS); |
| 721 | + |
| 722 | + $this->assertInstanceOf(TaggedValue::class, $value['foo']); |
| 723 | + $this->assertSame('bar', $value['foo']->getTag()); |
| 724 | + $this->assertSame('', $value['foo']->getValue()); |
| 725 | + } |
| 726 | + |
| 727 | + public function testTagWithEmptyValueInMapping() |
| 728 | + { |
| 729 | + $value = Inline::parse('{foo: !bar ""}', Yaml::PARSE_CUSTOM_TAGS); |
| 730 | + |
| 731 | + $this->assertInstanceOf(TaggedValue::class, $value['foo']); |
| 732 | + $this->assertSame('bar', $value['foo']->getTag()); |
| 733 | + $this->assertSame('', $value['foo']->getValue()); |
| 734 | + } |
698 | 735 | }
|
0 commit comments