0
以下測試從路徑加載所有Markdown文件。它在本地工作,但在Travis上隨機失敗。有時候,它通過沒有任何失敗,有時它通過一些PHP版本。這是正在測試的類是hereTravis測試失敗,但通過本地機器
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);
}
特拉維斯顯示了一個失敗的運行如下:
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>
'
)
)
你是絕對正確的,這很有道理。我已經重構/刪除了代碼,所以現在並不重要,但是謝謝你讓我知道爲什麼。 –