jsonArray = new JsonArray(
            '{"ticket": {"title": "Bug should be fixed", "user": {"name": "Davert"}, "labels": null}}'
        );
    }
    public function testXmlConversion()
    {
        $this->assertContains(
            'Bug should be fixedDavert',
            $this->jsonArray->toXml()->saveXML()
        );
    }
    public function testXmlArrayConversion2()
    {
        $jsonArray = new JsonArray(
            '[{"user":"Blacknoir","age":27,"tags":["wed-dev","php"]},'
            . '{"user":"John Doe","age":27,"tags":["web-dev","java"]}]'
        );
        $this->assertContains('wed-dev', $jsonArray->toXml()->saveXML());
        $this->assertEquals(2, $jsonArray->filterByXPath('//user')->length);
    }
    public function testXPathLocation()
    {
        $this->assertGreaterThan(0, $this->jsonArray->filterByXPath('//ticket/title')->length);
        $this->assertGreaterThan(0, $this->jsonArray->filterByXPath('//ticket/user/name')->length);
        $this->assertGreaterThan(0, $this->jsonArray->filterByXPath('//user/name')->length);
    }
    public function testJsonPathLocation()
    {
        $this->assertNotEmpty($this->jsonArray->filterByJsonPath('$..user'));
        $this->assertNotEmpty($this->jsonArray->filterByJsonPath('$.ticket.user.name'));
        $this->assertNotEmpty($this->jsonArray->filterByJsonPath('$..user.name'));
        $this->assertEquals(['Davert'], $this->jsonArray->filterByJsonPath('$.ticket.user.name'));
        $this->assertEmpty($this->jsonArray->filterByJsonPath('$..invalid'));
    }
    /**
     * @issue https://github.com/Codeception/Codeception/issues/2535
     */
    public function testThrowsInvalidArgumentExceptionIfJsonIsInvalid()
    {
        $this->setExpectedException('InvalidArgumentException');
        new JsonArray('{"test":');
    }
    /**
     * @issue https://github.com/Codeception/Codeception/issues/4944
     */
    public function testConvertsBareJson()
    {
        $jsonArray = new JsonArray('"I am a {string}."');
        $this->assertEquals(['I am a {string}.'], $jsonArray->toArray());
    }
    /**
     * @Issue https://github.com/Codeception/Codeception/issues/2899
     */
    public function testInvalidXmlTag()
    {
        $jsonArray = new JsonArray('{"a":{"foo/bar":1,"":2},"b":{"foo/bar":1,"":2},"baz":2}');
        $expectedXml = '12'
            . '122';
        $this->assertContains($expectedXml, $jsonArray->toXml()->saveXML());
    }
    public function testConvertsArrayHavingSingleElement()
    {
        $jsonArray = new JsonArray('{"success": 1}');
        $expectedXml = ''
            . "\n1\n";
        $this->assertEquals($expectedXml, $jsonArray->toXml()->saveXML());
    }
    public function testConvertsArrayHavingTwoElements()
    {
        $jsonArray = new JsonArray('{"success": 1, "info": "test"}');
        $expectedXml = ''
            . "\n1test\n";
        $this->assertEquals($expectedXml, $jsonArray->toXml()->saveXML());
    }
    public function testConvertsArrayHavingSingleSubArray()
    {
        $jsonArray = new JsonArray('{"array": {"success": 1}}');
        $expectedXml = ''
            . "\n1\n";
        $this->assertEquals($expectedXml, $jsonArray->toXml()->saveXML());
    }
}