<commit_before><?php

class ArrayToXmlConverterTest extends TestCase
{
    /**
     * @test
     */
    public function itShouldConvertTheArrayToXml()
    {
        $request = array(
            'auth' => array(
                'user' => 'some user',
                'password' => '<PASSWORD>',
                'context' => 2
            ),
            'task' => array(
                'code'   => '0101003',
                'domain' => array(
                    'name'                => 'some-domain.com',
                    'payable'             => '2012-01-15',
                    'period'              => 1,
                    'remove_cancellation' => 'no'
                )
            )
        );

        $expectedXml = <<<XML
<?xml version="1.0"encoding="utf-8" ?>
<request>
    <auth>
        <user>some user</user>
        <password><PASSWORD></password>
        <context>2</context>
    </auth>
    <task>
        <code>0101003</code>
        <domain>
            <name>some-domain.com</name>
            <payable>2012-01-15</payable>
            <period>1</period>
            <remove_cancellation>no</remove_cancellation>
        </domain>
    </task>
</request>
XML;

        $converter = new Tool\ArrayToXmlConverter();

        $this->assertEquals($this->removeWhiteSpaces($expectedXml), $this->removeWhiteSpaces($converter->convert($request)));
    }

    private function removeWhiteSpaces($string)
    {
        return preg_replace('/\s/', '', $string);
    }
}
<commit_msg>wip: adds ability to convert many keys to correct xml<commit_after><?php

class ArrayToXmlConverterTest extends TestCase
{
    /**
     * @test
     */
    public function itShouldConvertTheArrayToXml()
    {
        $request = array(
            'auth' => array(
                'user' => 'some user',
                'password' => '<PASSWORD>',
                'context' => 2
            ),
            'task' => array(
                'code'   => '0101003',
                'domain' => array(
                    'name'                => 'some-domain.com',
                    'payable'             => '2012-01-15',
                    'period'              => 1,
                    'remove_cancellation' => 'no'
                )
            )
        );

        $expectedXml = <<<XML
<?xml version="1.0"encoding="utf-8" ?>
<request>
    <auth>
        <user>some user</user>
        <password><PASSWORD></password>
        <context>2</context>
    </auth>
    <task>
        <code>0101003</code>
        <domain>
            <name>some-domain.com</name>
            <payable>2012-01-15</payable>
            <period>1</period>
            <remove_cancellation>no</remove_cancellation>
        </domain>
    </task>
</request>
XML;

        $this->assertRequestIsConvertedToExpectedXml($request, $expectedXml);
    }

    /**
     * @test
     */
    public function itShouldGenerateATagForEachValue()
    {
        $request = array(
            'task' => array(
                'code'                 => '0105',
                'domain'               => array(
                    'name' => 'some-domain.net'
                ),
                'key' => array('payable, created')
            )
        );

        $expectedXml = <<<XML
<?xml version="1.0"encoding="utf-8" ?>
<request>
    <task>
        <code>0105</code>
        <domain>
            <name>some-domain.net</name>
        </domain>
        <key>payable</key>
        <key>created</key>
    </task>
</request>
XML;

        $this->assertRequestIsConvertedToExpectedXml($request, $expectedXml);
    }

    /**
     * @param $request
     * @param $expectedXml
     */
    private function assertRequestIsConvertedToExpectedXml($request, $expectedXml)
    {
        $converter = new Tool\ArrayToXmlConverter();

        $this->assertEquals(
            $this->removeWhiteSpaces($expectedXml),
            $this->removeWhiteSpaces($converter->convert($request))
        );
    }

    private function removeWhiteSpaces($string)
    {
        return preg_replace('/\s/', '', $string);
    }
}

{'fraction_non_alphanumeric': 0.14908822079842288, 'fraction_numerical': 0.02094627895515032, 'mean_word_length': 1.502466091245376, 'pattern_counts': {'":': 0, '<': 83, '<?xml version=': 3, '>': 109, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1197720', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1156, 'n_words': 188}