Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / symfony / config / Tests / Util / XmlUtilsTest.php
index 29d64dba84205631c8c71b27e0514b258b8ec05a..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);
@@ -180,16 +194,11 @@ class XmlUtilsTest extends TestCase
             } catch (\InvalidArgumentException $e) {
                 $this->assertEquals(sprintf('File %s does not contain valid XML, it is empty.', $file), $e->getMessage());
             }
-        } catch (\Exception $e) {
+        } finally {
             restore_error_handler();
             error_reporting($errorReporting);
-
-            throw $e;
         }
 
-        restore_error_handler();
-        error_reporting($errorReporting);
-
         $disableEntities = libxml_disable_entity_loader(true);
         libxml_disable_entity_loader($disableEntities);