Skip to content

Instantly share code, notes, and snippets.

@petersuhm
Last active August 29, 2015 14:23
Show Gist options
  • Save petersuhm/ec04e497f3c9eca42086 to your computer and use it in GitHub Desktop.
Save petersuhm/ec04e497f3c9eca42086 to your computer and use it in GitHub Desktop.
Laravel 5.1 test example
<?php
use Illuminate\Foundation\Testing\DatabaseMigrations;
use WpShop\Product;
class ProductOverviewTest extends TestCase
{
use DatabaseMigrations;
/**
* @test
*/
public function it_can_list_all_products()
{
// With no products in DB
$this->visit('/admin/products')->see('No products');
// Populate DB
Product::create(['name' => 'WP Pusher']);
Product::create(['name' => 'Mailchimp for WordPress']);
// Chain test expectations
$this
// Go to product creation page
->visit('/admin/products')
// Make sure we see the products added
->see('WP Pusher')
->see('Mailchimp for WordPress')
;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment