Skip to content

Instantly share code, notes, and snippets.

@jamierumbelow
Created October 13, 2012 13:42
Show Gist options
  • Save jamierumbelow/3884671 to your computer and use it in GitHub Desktop.
Save jamierumbelow/3884671 to your computer and use it in GitHub Desktop.
Testing for Laravel 4
<?php
namespace App\Tests\Unit;
use App\Models\User as User;
class UserControllerTest extends \PHPUnit_Framework_TestCase
{
public function testMostPopular()
{
User::shouldReceive('getMostPopular')->andReturn('userData');
View::shouldReceive('make')->with('users.popular', 'userData');
(new UserController())->showMostPopular();
}
}
<?php
namespace App\Tests\Unit;
use App\Models\User as User;
class UserTest extends \PHPUnit_Framework_TestCase
{
public function testUserIsValidatedAppropriately()
{
$user = new User();
$user->assertValidated('email', 'valid_email'); // whatever
$user->assertValidated('password', 'min_length', 10); // whatever
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment