I have the following in my blade...
<div>
<contact-form></contact-form>
</div>
I want to test to ensure that the Vue.js component is always mounted in my tests...
public function testRoute()
{
$this->visit('/');
//stuck here
}
Basically I'mm looking forward to testing that the blade has <contact-form>
. How should I proceed?
By default, Laravel 5.8 uses PHPUnit 7. However, you may optionally upgrade to PHPUnit 8, which requires PHP >= 7.2. In addition, please read through the entire list of changes in the PHPUnit 8 release announcement.
Short response no, Laravel 8 requires PHP >= 7.3 From Server Requirements But, since you downgraded it is possible that some php packages require newer php versions no matter the version chosen for Laravel.
MVC Architecture of Laravel Framework Laravel architecture is MVC-based, and this is something that makes Laravel the best PHP framework for website development. MVC architecture comes up with built-in functionalities that developers can use at their best while building your web app.
Use assertSee
Assert that the given string is contained within the response
$this
->visit('/')
->assertSee('<contact-form>')
->assertSee('</contact-form>');
See more laravel 5.5 testing assertions here
Or if you want to get deeper into client side browser testing look at Laravel Dusk, it has assertSourceHas
method.
You can use the call
or get
method from MakesHttpRequests.php
trait to inspect the text:
// this returns \Illuminate\Foundation\Testing\TestResponse
$response = $this->get('/');
// use the TestResponse api
$response->assertSee($value);
Github source code reference: https://github.com/laravel/framework/blob/5.5/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php
https://github.com/laravel/framework/blob/5.5/src/Illuminate/Foundation/Testing/TestResponse.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With