ThinkPHP/Library/Vendor/spyc/tests/DumpTest.php
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
require_once ("../Spyc.php");
class DumpTest extends PHPUnit_Framework_TestCase {
private $files_to_test = array();
public function setUp() {
$this->files_to_test = array ('../spyc.yaml', 'failing1.yaml', 'indent_1.yaml', 'quotes.yaml');
}
public function testShortSyntax() {
$dump = spyc_dump(array ('item1', 'item2', 'item3'));
$awaiting = "- item1\n- item2\n- item3\n";
$this->assertEquals ($awaiting, $dump);
}
public function testDump() {
foreach ($this->files_to_test as $file) {
$yaml = spyc_load(file_get_contents($file));
$dump = Spyc::YAMLDump ($yaml);
$yaml_after_dump = Spyc::YAMLLoad ($dump);
$this->assertEquals ($yaml, $yaml_after_dump);
}
}
public function testDumpWithQuotes() {
$Spyc = new Spyc();
$Spyc->setting_dump_force_quotes = true;
foreach ($this->files_to_test as $file) {
$yaml = $Spyc->load(file_get_contents($file));
$dump = $Spyc->dump ($yaml);
$yaml_after_dump = Spyc::YAMLLoad ($dump);
$this->assertEquals ($yaml, $yaml_after_dump);
}
}
public function testDumpArrays() {
$dump = Spyc::YAMLDump(array ('item1', 'item2', 'item3'));
$awaiting = "---\n- item1\n- item2\n- item3\n";
$this->assertEquals ($awaiting, $dump);
}
public function testNull() {
$dump = Spyc::YAMLDump(array('a' => 1, 'b' => null, 'c' => 3));
$awaiting = "---\na: 1\nb: null\nc: 3\n";
$this->assertEquals ($awaiting, $dump);
}
public function testNext() {
$array = array("aaa", "bbb", "ccc");
#set arrays internal pointer to next element
next($array);
$dump = Spyc::YAMLDump($array);
$awaiting = "---\n- aaa\n- bbb\n- ccc\n";
$this->assertEquals ($awaiting, $dump);
}
public function testDumpingMixedArrays() {
后面还有 76 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
