for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace LaLit;
class MainLaLitTest extends \PHPUnit_Framework_TestCase
{
public function provideTestData()
return include __DIR__.'/files/testData.inc';
}
/**
* @dataProvider provideTestData
*
* @param string $php
* @param string $xml
* @param string $structure
*/
public function testArrayToXML($php, $xml, $structure)
$actualResults = Array2XML::createXML('root', $php['root'])->saveXML();
$php['root']
string
array
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
$expectedResults = $xml;
$this->assertEquals($expectedResults, $actualResults, $structure);
* @param string $xmlString
public function testXMLToArray($php, $xmlString, $structure)
$xmlDOM = new \DOMDocument(1.0, 'UTF-8');
$xmlDOM->xmlStandalone = false;
$xmlDOM->preserveWhiteSpace = false;
$xmlDOM->loadXML($xmlString);
$xmlDOM->formatOutput = true;
$xmlStringResults = XML2Array::createArray($xmlString);
$xmlDOMResults = XML2Array::createArray($xmlDOM);
$this->assertEquals($php, $xmlStringResults, $structure);
$this->assertEquals($php, $xmlDOMResults, $structure);
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: