Laravel View Test Suite

Laravel is a package for testing views alone. 

class WelcomeTest extends TestCase
{
// First, add the `InteractsWithViews` trait to your test case class.
use InteractsWithViews;
public function testDisplaysLaravel()
{
// Then, get started with Mojito using the `assertView` method.
$this->assertView('welcome')->contains('Laravel');
}
}

You can also use this package in HTTP tests:

$response = $this->get('/'); $response->assertStatus(200); $response->assertView()->contains('Laravel');

The API includes the following features during authoring:

  • contains() - verifies the text given to view
  • has() - view  verifies the given selector
  • hasAttribute() - verifies that an item is the specified property
  • hasClass() - view verifies that it is given class
  • hasLink() - view verifies the given connection

Here are a few more examples of package methods:

contains
$this->assertView('button')->contains('Click me');
particular
$this->assertView('welcome')->in('body')->has('.content')
hasAttribute
$this->assertView('button')->hasAttribute('attribute', 'value');
hasClass
$this->assertView('button')->hasClass('btn');
hasLink
$this->assertView('button')->hasLink('welcome'));

You can learn more about this package, get all the installation instructions and view the source code on GitHub from nunomaduro /laravel-mojito .

  Quote

KARABAY A, 2020 . Laravel View Test Suite,

https://www.karabayyazilim.com/blog/php/framework/laravel/laravel-view-test-paketi-2020-02-19-213629

(Accessed February 19, 2020).


  Share this post

Comments (0)

Comment

Subscribe
Sign up for the email newsletter to be the first to know about my blog posts