Answer the question
In order to leave comments, you need to log in
Why doesn't a simple Feature test work in laravel?
Hey guys.
Why does Test return an empty $article->id ?
-------------------------------------- Array ([$article->id] => )
_ ------------
class ArticlesController extends Controller
{
public function update(ArticleRequest $request, Article $article)
{
throw new Exception(print_r([
'$article->id' => $article->id
]));
}
}
class ArticleTest extends TestCase
{
public function test_article_update_success(): void
{
$this->withoutMiddleware();
$article = factory(Article::class)->create();
$putArr = [
'name' => $this->faker->name,
'body' => $this->faker->sentence,
];
$response = $this->put(route('admin.articles.update', $article), $putArr);
throw $response->exception;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question