下面的测试从路径加载所有Markdown文件。它在本地工作,但在特拉维斯身上随机失败。有时,它会在没有任何故障的情况下通过,有时它会传递一些PHP版本。正在测试的类是这里。
public function testLoadMultipleFiles()
{
$index_content = "<h2>This is a Sub Page Index</h2>" . PHP_EOL . PHP_EOL
. "<p>This is index.md in the 'sub' folder.</p>" . PHP_EOL . PHP_EOL
. "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>" . PHP_EOL . PHP_EOL
. "<p>Donec ultricies tristique nulla et mattis.</p>" . PHP_EOL. PHP_EOL
. "<p>Phasellus id massa eget nisl congue blandit sit amet id ligula.</p>" . PHP_EOL;
$sub_page_content = "<h2>This is a Sub Page</h2>" . PHP_EOL . PHP_EOL
. "<p>This is page.md in the 'sub' folder.</p>" . PHP_EOL . PHP_EOL
. "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>" . PHP_EOL . PHP_EOL
. "<p>Donec ultricies tristique nulla et mattis.</p>" . PHP_EOL . PHP_EOL
. "<p>Phasellus id massa eget nisl congue blandit sit amet id ligula.</p>". PHP_EOL;
// Create a stub for the SomeClass class.
$parser = $this->getMock('Michelf\MarkdownInterface', array('defaultTransform', 'transform'));
$parser::staticExpects($this->at(0))
->method('defaultTransform')
->will($this->returnValue($index_content));
$parser::staticExpects($this->at(1))
->method('defaultTransform')
->will($this->returnValue($sub_page_content));
$loader = new MarkdownLoader($parser);
$files['sub/index.md'] = array(
'meta' => array(
'title' => 'Sub Page Index'
),
'content' => $index_content
);
$files['sub/page.md'] = array(
'meta' => array(
'title' => 'Sub Page'
),
'content' => $sub_page_content
);
$result = $loader->load(ROOT_DIR . 'content/sub', array('md'));
$this->assertEquals($files, $result);
}Travis在失败的运行中显示了以下内容:
There was 1 failure:
1) Zepto\FileLoader\MarkdownLoaderTest::testLoadMultipleFiles
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
'sub/index.md' => Array (
'meta' => Array (...)
- 'content' => '<h2>This is a Sub Page Index</h2>
+ 'content' => '<h2>This is a Sub Page</h2>
- <p>This is index.md in the 'sub' folder.</p>
+ <p>This is page.md in the 'sub' folder.</p>
@@ @@
'meta' => Array (...)
- 'content' => '<h2>This is a Sub Page</h2>
+ 'content' => '<h2>This is a Sub Page Index</h2>
- <p>This is page.md in the 'sub' folder.</p>
+ <p>This is index.md in the 'sub' folder.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Donec ultricies tristique nulla et mattis.</p>
<p>Phasellus id massa eget nisl congue blandit sit amet id ligula.</p>
'
)
)发布于 2014-03-11 01:52:43
很抱歉拖延了很长时间。
只是猜测一下,但是您在本地使用Mac吗?
Mac按字母顺序返回列表,但在linux上文件系统以随机顺序列出文件。
在您的测试错误消息中,您可以看到每个读取的文件都得到了它所期望的相反的结果,即index或sub page,这使我相信由于目录列表而失败的测试出现了一个随机错误(当它通过文件系统时,它以正确的顺序返回这两个文件)。我不知道任何的单位,所以我不能帮助你的具体情况不幸。
https://stackoverflow.com/questions/21394252
复制相似问题