Added basic controller unit tests
This commit is contained in:
33
app/tests/Controllers/Api/ComponentControllerTest.php
Normal file
33
app/tests/Controllers/Api/ComponentControllerTest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
class ComponentControllerTest extends TestCase {
|
||||
|
||||
public function setUp() {
|
||||
$this->repo = Mockery::mock('CachetHQ\Cachet\Repositories\Component\ComponentRepository');
|
||||
$this->dingo = Mockery::mock('Dingo\Api\Auth\Shield');
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
Mockery::close();
|
||||
}
|
||||
|
||||
public function test_get_components_method()
|
||||
{
|
||||
$this->repo->shouldReceive('all')->once()->andReturn('foo');
|
||||
|
||||
$controller = new CachetHQ\Cachet\Controllers\Api\ComponentController($this->dingo, $this->repo);
|
||||
$response = $controller->getComponents();
|
||||
|
||||
$this->assertEquals('foo', $response);
|
||||
}
|
||||
|
||||
public function test_get_component_method()
|
||||
{
|
||||
$this->repo->shouldReceive('findOrFail')->with(1)->once()->andReturn('foo');
|
||||
|
||||
$controller = new CachetHQ\Cachet\Controllers\Api\ComponentController($this->dingo, $this->repo);
|
||||
$response = $controller->getComponent(1);
|
||||
|
||||
$this->assertEquals('foo', $response);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
class ExampleTest extends TestCase {
|
||||
|
||||
/**
|
||||
* A basic functional test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBasicExample()
|
||||
{
|
||||
$crawler = $this->client->request('GET', '/');
|
||||
|
||||
$this->assertTrue($this->client->getResponse()->isOk());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user