您好我正忙于编辑和更改测试类以使用laravel 4.2,我现在已经对模型进行了更改但是它经常抛出异常,AllRoutesTest :: withoutEvents()是未定义的方法。有什么东西我不见了吗?
<?php
class AllRoutesTest extends TestCase
{
protected $admin;
public function setUp()
{
parent::setUp();
$this->admin = User::find(1);
}
/**
* test all route
*
* @group route
*/
public function testAllRoute()
{
$routeCollection = Route::getRoutes();
$this->withoutEvents();
$blacklist = [
'url/that/not/tested',
];
$dynamicReg = "/{\\S*}/"; //used for omitting dynamic urls that have {} in uri
$this->be($this->admin);
foreach ($routeCollection as $route) {
if (!preg_match($dynamicReg, $route->getUri()) &&
in_array('GET', $route->getMethods()) &&
!in_array($route->getUri(), $blacklist)
) {
$start = $this->microtimeFloat();
fwrite(STDERR, print_r('test ' . $route->getUri() . "\n", true));
$response = $this->call('GET', $route->getUri());
$end = $this->microtimeFloat();
$temps = round($end - $start, 3);
fwrite(STDERR, print_r('time: ' . $temps . "\n", true));
$this->assertLessThan(15, $temps, "too long time for " . $route->getUri());
$this->assertEquals(200, $response->getStatusCode(), $route->getUri() . "failed to load");
}
}
}
public function microtimeFloat()
{
list($usec, $asec) = explode(" ", microtime());
return ((float) $usec + (float) $asec);
}
}