Issues (41)

tests/src/XmlTest.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Nip\Utility\Tests;
4
5
use Nip\Utility\Xml;
6
7
/**
8
 * Class XmlTest
9
 * @package Nip\Utility\Tests
10
 */
11
class XmlTest extends AbstractTest
12
{
13
    public function test_validate_with_url()
14
    {
15
        $this->expectNotToPerformAssertions();
16
17
        Xml::validate(
18
            file_get_contents(TEST_FIXTURE_PATH . '/Xml/request.xml'),
19
            'https://secure.plationline.ro/xml_validation/po.request.v5.xsd'
20
        );
21
    }
22
23
    public function test_toObject()
24
    {
25
        $xml = file_get_contents(TEST_FIXTURE_PATH . '/Xml/request.xml');
26
        $object = Xml::toObject($xml);
27
        self::assertInstanceOf(\SimpleXMLElement::class, $object);
28
    }
29
30
    public function test_fromArray()
31
    {
32
        $object = Xml::fromArray(['myKey' => ['myAtrr' => 5, 'myAttr2' => 'My Value']]);
33
        self::assertInstanceOf(\SimpleXMLElement::class, $object);
34
        self::assertSame(
35
            '<?xml version="1.0" encoding="UTF-8"?>
36
<myKey><myAtrr>5</myAtrr><myAttr2>My Value</myAttr2></myKey>
37
',
38
            $object->asXML()
0 ignored issues
show
The method asXML() does not exist on DOMDocument. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
            $object->/** @scrutinizer ignore-call */ 
39
                     asXML()

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
39
        );
40
    }
41
}
42