Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / symfony / config / Tests / Util / XmlUtilsTest.php
index 161dc61721c125b6815142335a57ea3fe30d1a78..10b4a7a9b4dc7a581495b50502d581c54555d354 100644 (file)
@@ -55,13 +55,27 @@ class XmlUtilsTest extends TestCase
             XmlUtils::loadFile($fixtures.'valid.xml', array($mock, 'validate'));
             $this->fail();
         } catch (\InvalidArgumentException $e) {
-            $this->assertContains('is not valid', $e->getMessage());
+            $this->assertRegExp('/The XML file ".+" is not valid\./', $e->getMessage());
         }
 
         $this->assertInstanceOf('DOMDocument', XmlUtils::loadFile($fixtures.'valid.xml', array($mock, 'validate')));
         $this->assertSame(array(), libxml_get_errors());
     }
 
+    /**
+     * @expectedException \Symfony\Component\Config\Util\Exception\InvalidXmlException
+     * @expectedExceptionMessage The XML is not valid
+     */
+    public function testParseWithInvalidValidatorCallable()
+    {
+        $fixtures = __DIR__.'/../Fixtures/Util/';
+
+        $mock = $this->getMockBuilder(__NAMESPACE__.'\Validator')->getMock();
+        $mock->expects($this->once())->method('validate')->willReturn(false);
+
+        XmlUtils::parse(file_get_contents($fixtures.'valid.xml'), array($mock, 'validate'));
+    }
+
     public function testLoadFileWithInternalErrorsEnabled()
     {
         $internalErrors = libxml_use_internal_errors(true);