mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-01 00:02:21 +09:00
Fix var_export() not working for stdClass in PHP < 7.3
This commit is contained in:
parent
a2c9274681
commit
3f7f802585
8 changed files with 40 additions and 43 deletions
|
|
@ -18,9 +18,5 @@ class ConfigTest extends \Codeception\TestCase\Test
|
|||
Rhymix\Framework\Config::set('foo.bar', $rand = mt_rand());
|
||||
$this->assertEquals(array('bar' => $rand), Rhymix\Framework\Config::get('foo'));
|
||||
$this->assertEquals($rand, Rhymix\Framework\Config::get('foo.bar'));
|
||||
|
||||
$var = array('foo' => 'bar');
|
||||
$serialized = "array(\n\t'foo' => 'bar',\n)";
|
||||
$this->assertEquals($serialized, Rhymix\Framework\Config::serialize($var));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,6 +103,21 @@ class FunctionsTest extends \Codeception\TestCase\Test
|
|||
$this->assertEquals('Rhymix ^~', base64_decode_urlsafe('Umh5bWl4IF5-'));
|
||||
}
|
||||
|
||||
public function testVarExportClean()
|
||||
{
|
||||
$obj = new stdClass;
|
||||
$obj->foo = 42;
|
||||
$obj->bar = 7;
|
||||
if (version_compare(PHP_VERSION, '7.3', '<'))
|
||||
{
|
||||
$this->assertEquals("(object)(array(\n 'foo' => 42,\n 'bar' => 7,\n))", var_export_clean($obj));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->assertEquals("(object) array(\n 'foo' => 42,\n 'bar' => 7,\n)", var_export_clean($obj));
|
||||
}
|
||||
}
|
||||
|
||||
public function testHex2Rgb2Hex()
|
||||
{
|
||||
$this->assertEquals(array(128, 128, 128), hex2rgb('808080'));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue