【发布时间】:2019-11-10 23:31:15
【问题描述】:
我正在运行 PHP 7.2 (WAMP 3.1)、PHPUnit 8.2.3、PhpStorm 2019.1,但我认为这不是配置问题,因为我之前从同一个文件进行的测试似乎按预期工作,并且所有测试通过。这是“失败”的功能测试和随附的代码。
测试:
/**@test*/
public function a_user_can_view_a_project(){
$this->withoutExceptionHandling();
$project = factory('App\Project')->create();
$this->get('/projects/'.$project->id)
->assertSee('title')
->assertSee('description');
}
路线:
Route::get('/projects/{project}', 'ProjectsController@show');
控制器功能:
public function show(Project $project){
return view('projects.show', compact('project'));
}
迁移:
class CreateProjectsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('projects', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('title');
$table->text('description');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('projects');
}
}
工厂:
$factory->define(Project::class, function (Faker $faker) {
return [
'title' => $faker->sentence,
'description' => $faker->paragraph
];
});
【问题讨论】:
标签: php laravel phpunit phpstorm