PHP code example of mikerogne / laravel-tag-assertions

1. Go to this page and download the library: Download mikerogne/laravel-tag-assertions library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mikerogne / laravel-tag-assertions example snippets




namespace Tests\Feature;

class ExampleTest extends TestCase
{
    /** @test */
    public function uses_old_input_when_validation_fails()
    {
        $data = [
            'first_name' => 'John',
            'last_name' => 'Doe',
            'email' => '', // oops!
        ];
        
        $response = $this->post('/register', $data);
        
        $response->assertSeeTag('input[name=first_name]', [
            'value' => $data['first_name'],
        ]);
        
        $response->assertSeeTag('input[name=last_name]', [
            'value' => $data['last_name'],
        ]);
    }
}



namespace Tests\Feature;

class VueTest extends TestCase
{
    /** @test */
    public function lists_blog_posts()
    {
        $posts = factory(\App\Post::class, 5)->create();
        
        $response = $this->get('/', $data);
        
        $response->assertSeeTagContent('h1', 'Another Contrived Example');
        
        $response->assertSeeTag('blog-posts', [
            ':posts' => e($posts->toJson()),
        ]);
    }
}



namespace Tests\Feature;

class CallbackTest extends TestCase
{
    /** @test */
    public function shows_product_review()
    {
        $response = $this->get('/', $data);
        
        $response->assertSeeTag('h2', function($tag, $attributes, $content) {
            // $tag -> "h2"
            // $attributes -> ['class' => 'section-title', 'data-foobar' => 'bazburk']
            // $content -> Product Review (but including the whitespace!)
            
            return \Illuminate\Support\Str::contains($content, 'Product Review');
        });
        
        $response->assertSeeTagContent('p.summary', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.');
    }
}