mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 13:38:20 +01:00
Added basic controller unit tests
This commit is contained in:
parent
557e24ade1
commit
1144df4023
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());
|
||||
}
|
||||
}
|
@ -12,7 +12,8 @@
|
||||
"thujohn/rss": "dev-master"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.3.0"
|
||||
"phpunit/phpunit": "~4.3.0",
|
||||
"mockery/mockery": "0.9.*"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
|
68
composer.lock
generated
68
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "ae2cfb2f8386f3b5f6fd63b350807b5a",
|
||||
"hash": "da2246ff474233efc51049860a882331",
|
||||
"packages": [
|
||||
{
|
||||
"name": "classpreloader/classpreloader",
|
||||
@ -2106,6 +2106,72 @@
|
||||
],
|
||||
"time": "2014-10-13 12:58:55"
|
||||
},
|
||||
{
|
||||
"name": "mockery/mockery",
|
||||
"version": "0.9.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/padraic/mockery.git",
|
||||
"reference": "95a4855380dc70176c51807c678fb3bd6198529a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/padraic/mockery/zipball/95a4855380dc70176c51807c678fb3bd6198529a",
|
||||
"reference": "95a4855380dc70176c51807c678fb3bd6198529a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"lib-pcre": ">=7.0",
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"hamcrest/hamcrest-php": "~1.1",
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"satooshi/php-coveralls": "~0.7@dev"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.9.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Mockery": "library/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Pádraic Brady",
|
||||
"email": "padraic.brady@gmail.com",
|
||||
"homepage": "http://blog.astrumfutura.com"
|
||||
},
|
||||
{
|
||||
"name": "Dave Marshall",
|
||||
"email": "dave.marshall@atstsolutions.co.uk",
|
||||
"homepage": "http://davedevelopment.co.uk"
|
||||
}
|
||||
],
|
||||
"description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succint API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.",
|
||||
"homepage": "http://github.com/padraic/mockery",
|
||||
"keywords": [
|
||||
"BDD",
|
||||
"TDD",
|
||||
"library",
|
||||
"mock",
|
||||
"mock objects",
|
||||
"mockery",
|
||||
"stub",
|
||||
"test",
|
||||
"test double",
|
||||
"testing"
|
||||
],
|
||||
"time": "2014-09-03 10:11:10"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
"version": "2.0.11",
|
||||
|
Loading…
x
Reference in New Issue
Block a user