$t->assertFalse($objects[0]['should_not_exist']); $t->assertEquals($objects[0]['msgid'], 'Password'); $t->assertEquals($objects[0]['msgstr'], 'Mot de passe:'); $t->assertEquals($objects[1]['msgid'], "Hard idfoo bar\na \" quote"); $t->assertEquals($objects[2]['msgid'], 'Passwordxxx'); $t->assertEquals($objects[2]['msgstr'], 'Mot de passe:xxx'); $t->assertTrue($objects[2]['is_obsolete']); $t1 = "dog"; $t2 = "foo\nbar"; $t2 = 'foo\\"b\\na\\r'; $t->assertEquals($parser->encodeStringFormat('dog'), '"dog"'); $t->assertEquals($parser->encodeStringFormat("dog\ncat"), "\"\"\n\"dog\\n\"\n\"cat\""); //$t->assertEquals($parser->decodeStringFormat( $parser->encodeStringFormat($t2) ),$t2); //$t->assertEquals($parser->decodeStringFormat( $parser->encodeStringFormat($t3) ),$t3); var_dump($objects); $t->printResults(); class Tester { public $pass_count = 0; public $fail_count = 0; function assertEquals($a, $b, $message = "") { if ($a !== $b) { $a_str = var_export($a, true); $b_str = var_export($b, true); echo "Test Failed: ({$a_str} not equal to {$b_str}) {$message}\n"; $this->fail_count++; } else { $this->pass_count++; } }
<?php require_once 'Tester.php'; $tests = array('eval' => 'php', 'unserialize' => 'phps', 'json_decode' => 'json'); $data = array(); foreach ($tests as $test) { include_once "data_{$test}.php"; } $tester = new Tester(1000); $tester->setTestData($data); $tester->setTests($tests); $tester->runTests(); $tester->printResults();