目前,在关于编写测试的Laravel 4书之后,如果函数名为link_to()
,则以下方法不返回PHPUnit的输出,但如果将其命名为link_tox()
,则会返回结果。这是为什么?
应用/ helpers.php
<?php
function link_to($url, $body) {
$url = url($url);
return "<a href='{$url}'>{$body}</a>";
}
应用/测试/ ExampleTests.php
<?php
class FunctionsTest extends TestCase {
public function testGeneratesAnchorTag() {
$actual = link_to('dogs/1', 'Show Dog');
$expected = "<a href='http://localhost/dogs/1'>Show Dog</a>";
$this->assertEquals($expected, $actual);
}
}