Now tests if a component can be created via the API

This commit is contained in:
James Brooks
2015-06-02 09:00:33 +01:00
parent f550a7369e
commit ee66f4c451
+29 -11
View File
@@ -18,15 +18,6 @@ class ComponentTest extends AbstractTestCase
{ {
use DatabaseMigrations; use DatabaseMigrations;
/**
* @before
*/
public function letUserBeLoggedIn()
{
$user = factory('CachetHQ\Cachet\Models\User')->create();
$this->be($user);
}
public function testGetComponents() public function testGetComponents()
{ {
$this->get('/api/v1/components')->seeJson(['data' => []]); $this->get('/api/v1/components')->seeJson(['data' => []]);
@@ -45,8 +36,35 @@ class ComponentTest extends AbstractTestCase
$this->assertResponseStatus(401); $this->assertResponseStatus(401);
} }
public function testPostComponentAuthorizedNoData() public function testPostComponentNoData()
{ {
$this->actingAs($this->user)->post('/api/v1/components')->seeJson(['Hello']); $this->user = factory('CachetHQ\Cachet\Models\User')->create();
$this->be($this->user);
$this->post('/api/v1/components');
$this->assertResponseStatus(400);
}
public function testPostComponent()
{
$this->user = factory('CachetHQ\Cachet\Models\User')->create();
$this->be($this->user);
$this->post('/api/v1/components', [
'name' => 'Foo',
'description' => 'Bar',
'status' => 1,
'link' => 'http://example.com',
'order' => 1,
'group_id' => 1,
])->seeJson(['name' => 'Foo']);
}
public function testGetNewComponent()
{
$this->user = factory('CachetHQ\Cachet\Models\User')->create();
$this->be($this->user);
$this->get('/api/v1/components/1')->seeJson(['name' => 'Foo']);
} }
} }