本文整理汇总了PHP中app\Board::take方法的典型用法代码示例。如果您正苦于以下问题:PHP Board::take方法的具体用法?PHP Board::take怎么用?PHP Board::take使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Board
的用法示例。
在下文中一共展示了Board::take方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testModelAndViews
/**
* Tests the board model and depndant views.
*
* @return void
*/
public function testModelAndViews()
{
// Get a board.
$boards = Board::take(1)->get();
// Get a board that cannot exist.
// The maximum `board_uri` length should be, at most, 31.
$noBoards = Board::where('board_uri', "12345678901234567890123456789012")->take(1)->get();
$this->assertInstanceOf("Illuminate\\Database\\Eloquent\\Collection", $boards);
$this->assertInstanceOf("Illuminate\\Database\\Eloquent\\Collection", $noBoards);
$this->assertEquals(0, count($noBoards));
if (count($boards)) {
$this->board = $board = $boards[0];
$this->assertInstanceOf("App\\Board", $board);
// Test relationships
$this->assertInstanceOf("Illuminate\\Database\\Eloquent\\Relations\\HasMany", $board->posts());
$this->assertInstanceOf("Illuminate\\Database\\Eloquent\\Relations\\HasMany", $board->logs());
$this->assertInstanceOf("Illuminate\\Database\\Eloquent\\Relations\\HasMany", $board->threads());
$this->assertInstanceOf("Illuminate\\Database\\Eloquent\\Relations\\HasMany", $board->roles());
// Test modern routes
$response = $this->call('GET', url("{$board->board_uri}"));
$this->assertEquals(200, $response->getStatusCode());
$this->doBoardIndexAssertions();
$response = $this->call('GET', url("{$board->board_uri}/1"));
$this->assertEquals(200, $response->getStatusCode());
$this->doBoardIndexAssertions();
$response = $this->call('GET', url("{$board->board_uri}/catalog"));
$this->assertEquals(200, $response->getStatusCode());
$response = $this->call('GET', url("{$board->board_uri}/logs"));
$this->assertEquals(200, $response->getStatusCode());
$this->assertViewHas('board');
$this->assertViewHas('logs');
// Test legacy routes
$legacyCode = env('LEGACY_ROUTES', false) ? 302 : 404;
$response = $this->call('GET', url("{$board->board_uri}/index.html"));
$this->assertEquals($legacyCode, $response->getStatusCode());
$response = $this->call('GET', url("{$board->board_uri}/1.html"));
$this->assertEquals($legacyCode, $response->getStatusCode());
$response = $this->call('GET', url("{$board->board_uri}/catalog.html"));
$this->assertEquals($legacyCode, $response->getStatusCode());
} else {
$this->assertEquals(0, Board::count());
}
}