comparison core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
57 * Tests that invalid YAML throws an exception. 57 * Tests that invalid YAML throws an exception.
58 * 58 *
59 * @covers ::decode 59 * @covers ::decode
60 */ 60 */
61 public function testError() { 61 public function testError() {
62 $this->setExpectedException(InvalidDataTypeException::class); 62 if (method_exists($this, 'expectException')) {
63 $this->expectException(InvalidDataTypeException::class);
64 }
65 else {
66 $this->setExpectedException(InvalidDataTypeException::class);
67 }
63 YamlSymfony::decode('foo: [ads'); 68 YamlSymfony::decode('foo: [ads');
64 } 69 }
65 70
66 /** 71 /**
67 * Ensures that php object support is disabled. 72 * Ensures that php object support is disabled.
68 * 73 *
69 * @covers ::encode 74 * @covers ::encode
70 */ 75 */
71 public function testObjectSupportDisabled() { 76 public function testObjectSupportDisabled() {
72 $this->setExpectedException(InvalidDataTypeException::class, 'Object support when dumping a YAML file has been disabled.'); 77 if (method_exists($this, 'expectException')) {
78 $this->expectException(InvalidDataTypeException::class);
79 $this->expectExceptionMessage('Object support when dumping a YAML file has been disabled.');
80 }
81 else {
82 $this->setExpectedException(InvalidDataTypeException::class, 'Object support when dumping a YAML file has been disabled.');
83 }
73 $object = new \stdClass(); 84 $object = new \stdClass();
74 $object->foo = 'bar'; 85 $object->foo = 'bar';
75 YamlSymfony::encode([$object]); 86 YamlSymfony::encode([$object]);
76 } 87 }
77 88