Skip to content

Instantly share code, notes, and snippets.

@Cayan
Created October 19, 2016 21:24
Show Gist options
  • Save Cayan/f1d997bcd5c1a63b3129fa843a804f0d to your computer and use it in GitHub Desktop.
Save Cayan/f1d997bcd5c1a63b3129fa843a804f0d to your computer and use it in GitHub Desktop.
<?php
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class UserCRUDFailureTest extends TestCase
{
use DatabaseMigrations, DatabaseTransactions;
protected $prefix = '';
protected function setUp()
{
parent::setUp();
factory(App\User::class)->create();
factory(App\User::class)->create();
}
public function testRead()
{
$response = $this->call('GET', $this->prefix . '/3');
$actual = $response->getStatusCode();
$expected = \Illuminate\Http\Response::HTTP_UNPROCESSABLE_ENTITY;
$this->assertEquals($expected, $actual);
}
public function testUpdate()
{
$newName = 'Daniel Pinto';
$response = $this->call('PUT', $this->prefix . '/', [
'id' => 3,
'name' => $newName
], [], [], $this->transformHeadersToServerVars([
'Accept' => 'application/json',
'CONTENT_TYPE' => 'x-www-form-urlencoded'
]));
$actual = $response->getStatusCode();
$expected = \Illuminate\Http\Response::HTTP_UNPROCESSABLE_ENTITY;
$this->assertEquals($expected, $actual);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment