Open In App

PHPUnit assertXmlFileNotEqualsXmlFile() Function

The assertXmlFileNotEqualsXmlFile() function is a builtin function in PHPUnit and is used to assert whether the actual XML file Content is not equals to expected XML file content. This assertion will return true in the case if the expected XML file content is not the same as the actual XML file content else returns false. In case of true the asserted test case got passed else test case got failed.

Syntax:



assertXmlFileNotEqualsXmlFile(string $expectedFile, 
string $actualFile[, string $message = ''])

Parameters: This function accepts three parameters as mentioned above and described below:

Below examples illustrate the assertXmlFileNotEqualsXmlFile() function in PHPUnit:



Example 1:




<?php 
use PHPUnit\Framework\TestCase; 
    
class GeeksPhpunitTestCase extends TestCase 
    public function testNegativeTestcaseForassertXmlFileNotEqualsXmlFile()
    
        $actualFile '/home/lovely/Documents/php/actual.xml';
        $expectedFile    = '/home/lovely/Documents/php/expected.xml'
        // Assert function to test whether given 
        // expected xml file is not equal to actual xml file
        $this->assertXmlFileNotEqualsXmlFile(
            $actualFile,
            $expectedFile
            "actual xml file is not equal to expected xml file"
        ); 
    
    
?> 

Output:

PHPUnit 8.5.8 by Sebastian Bergmann and contributors.

F                                                               1 / 1 (100%)

Time: 89 ms, Memory: 10.00 MB

There was 1 failure:

1) GeeksPhpunitTestCase::testNegativeTestcaseForassertXmlFileNotEqualsXmlFile
actual xml file is not equal to expected xml file
Failed asserting that DOMDocument Object &000000000788a1260000000067204f26 
() is not equal to DOMDocument Object &000000000788a1210000000067204f26 ().

/home/lovely/Documents/php/test.php:16

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

Example 2:




<?php 
use PHPUnit\Framework\TestCase; 
    
class GeeksPhpunitTestCase extends TestCase 
    public function testPositiveTestcaseForassertXmlFileNotEqualsXmlFile()
    
        $actualFile '/home/lovely/Documents/php/actual.xml';
        $expectedFile    = '/home/lovely/Documents/php/expected.xml'
        // Assert function to test whether given 
        // expected xml file is not equal to actual xml file
        $this->assertXmlFileNotEqualsXmlFile(
            $actualFile,
            $expectedFile
            "actual xml file is not equal to expected xml file"
        ); 
    
    
?> 

Output:

PHPUnit 8.5.8 by Sebastian Bergmann and contributors.

.                                                1 / 1 (100%)

Time: 88 ms, Memory: 10.00 MB

OK (1 test, 1 assertion)

Article Tags :