From 7b3f6fee26db3b88894513e2eb4cd9726c75f54e Mon Sep 17 00:00:00 2001 From: James Brooks Date: Thu, 28 May 2015 18:18:33 +0100 Subject: [PATCH] Started working on a test suite Signed-off-by: Graham Campbell --- composer.json | 7 +- composer.lock | 167 ++++++++++++++++++++++++++++++- config/database.php | 2 +- phpunit.xml.dist | 2 + tests/AbstractTestCase.php | 29 ++++++ tests/ExampleTest.php | 23 ----- tests/Functional/CommandTest.php | 27 +++++ tests/TestCase.php | 27 ----- 8 files changed, 229 insertions(+), 55 deletions(-) create mode 100644 tests/AbstractTestCase.php delete mode 100644 tests/ExampleTest.php create mode 100644 tests/Functional/CommandTest.php delete mode 100644 tests/TestCase.php diff --git a/composer.json b/composer.json index c26d44c3..3f3b73f9 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,7 @@ "barryvdh/laravel-cors": "^0.5" }, "require-dev": { + "graham-campbell/testbench": "^2.1", "phpunit/phpunit": "^4.4", "mockery/mockery": "^0.9" }, @@ -53,9 +54,9 @@ } }, "autoload-dev": { - "classmap": [ - "tests/TestCase.php" - ] + "psr-4": { + "CachetHQ\\Tests\\Cachet\\": "tests/" + } }, "scripts": { "post-install-cmd": [ diff --git a/composer.lock b/composer.lock index fd5656a0..2ef3e93e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "f84e1802797ac9d788fa551927e87a70", + "hash": "852749758f495fdc944891946fbdef85", "packages": [ { "name": "asm89/stack-cors", @@ -3350,6 +3350,60 @@ ], "time": "2014-10-13 12:58:55" }, + { + "name": "graham-campbell/testbench", + "version": "v2.1.0", + "source": { + "type": "git", + "url": "https://github.com/GrahamCampbell/Laravel-TestBench.git", + "reference": "deea0e8cb8f6ee9c4032c24a40365eb334617a60" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/GrahamCampbell/Laravel-TestBench/zipball/deea0e8cb8f6ee9c4032c24a40365eb334617a60", + "reference": "deea0e8cb8f6ee9c4032c24a40365eb334617a60", + "shasum": "" + }, + "require": { + "mockery/mockery": "~0.9.4", + "orchestra/testbench": "3.0.*|3.1.*", + "php": ">=5.5.9", + "phpunit/phpunit": "~4.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "psr-4": { + "GrahamCampbell\\TestBench\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "graham@mineuk.com" + } + ], + "description": "TestBench Provides Some Testing Functionality For Laravel 5", + "keywords": [ + "Graham Campbell", + "GrahamCampbell", + "Laravel TestBench", + "Laravel-TestBench", + "TestBench", + "framework", + "laravel", + "testing" + ], + "time": "2015-04-24 19:37:19" + }, { "name": "hamcrest/hamcrest-php", "version": "v1.2.2", @@ -3460,6 +3514,117 @@ ], "time": "2015-04-02 19:54:00" }, + { + "name": "orchestra/database", + "version": "v3.0.4", + "source": { + "type": "git", + "url": "https://github.com/orchestral/database.git", + "reference": "0ad5e77155ae6443d228bf1174cf8dc426290738" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/orchestral/database/zipball/0ad5e77155ae6443d228bf1174cf8dc426290738", + "reference": "0ad5e77155ae6443d228bf1174cf8dc426290738", + "shasum": "" + }, + "require": { + "illuminate/contracts": "5.0.*", + "illuminate/database": "5.0.*", + "php": ">=5.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "psr-4": { + "Orchestra\\Database\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mior Muhammad Zaki", + "email": "crynobone@gmail.com", + "homepage": "https://github.com/crynobone" + }, + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com", + "homepage": "https://github.com/taylorotwell" + } + ], + "description": "Database Component for Orchestra Platform", + "time": "2015-03-02 11:01:05" + }, + { + "name": "orchestra/testbench", + "version": "v3.0.7", + "source": { + "type": "git", + "url": "https://github.com/orchestral/testbench.git", + "reference": "468db68c6c96e67905156f507c431a9e387d43e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/orchestral/testbench/zipball/468db68c6c96e67905156f507c431a9e387d43e4", + "reference": "468db68c6c96e67905156f507c431a9e387d43e4", + "shasum": "" + }, + "require": { + "laravel/framework": "5.0.*", + "orchestra/database": "3.0.*", + "php": ">=5.4.0" + }, + "require-dev": { + "behat/behat": "~2.5", + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "behat/behat": "Allow to use Behat for testing your Laravel Application/Package (~2.5).", + "phpunit/phpunit": "Allow to use PHPUnit for testing your Laravel Application/Package (~4.0)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "psr-4": { + "Orchestra\\Testbench\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mior Muhammad Zaki", + "email": "crynobone@gmail.com", + "homepage": "https://github.com/crynobone" + } + ], + "description": "Laravel Package Unit Testing Helper", + "homepage": "http://orchestraplatform.com/docs/latest/components/testbench/", + "keywords": [ + "BDD", + "TDD", + "laravel", + "orchestra-platform", + "orchestral", + "testing" + ], + "time": "2015-05-27 03:35:20" + }, { "name": "phpdocumentor/reflection-docblock", "version": "2.0.4", diff --git a/config/database.php b/config/database.php index 70e0c569..08c6b442 100644 --- a/config/database.php +++ b/config/database.php @@ -57,7 +57,7 @@ return [ 'sqlite' => [ 'driver' => 'sqlite', - 'database' => storage_path().'/database.sqlite', + 'database' => env('DB_HOST', storage_path().'/database.sqlite'), 'prefix' => '', ], diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b1c1d602..952f64fe 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -26,6 +26,8 @@ + + diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php new file mode 100644 index 00000000..e7b9c9f4 --- /dev/null +++ b/tests/AbstractTestCase.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CachetHQ\Tests\Cachet; + +use GrahamCampbell\TestBench\AbstractAppTestCase; + +abstract class AbstractTestCase extends AbstractAppTestCase +{ + /** + * Get the service provider class. + * + * @param \Illuminate\Contracts\Foundation\Application $app + * + * @return string + */ + protected function getServiceProviderClass($app) + { + return 'CachetHQ\Cachet\Providers\AppServiceProvider'; + } +} diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php deleted file mode 100644 index 9ecd0c71..00000000 --- a/tests/ExampleTest.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -class ExampleTest extends TestCase -{ - /** - * A basic functional test example. - */ - public function testBasicExample() - { - $true = true; - - $this->assertTrue($true); - } -} diff --git a/tests/Functional/CommandTest.php b/tests/Functional/CommandTest.php new file mode 100644 index 00000000..e919df7f --- /dev/null +++ b/tests/Functional/CommandTest.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CachetHQ\Tests\Cachet\Functional; + +use CachetHQ\Tests\Cachet\AbstractTestCase; + +class CommandTest extends AbstractTestCase +{ + public function testMigrations() + { + $this->assertSame(0, $this->getKernel()->call('migrate', ['--force' => true])); + } + + protected function getKernel() + { + return $this->app->make('Illuminate\Contracts\Console\Kernel'); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php deleted file mode 100644 index b8d557af..00000000 --- a/tests/TestCase.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -class TestCase extends Illuminate\Foundation\Testing\TestCase -{ - /** - * Creates the application. - * - * @return \Illuminate\Foundation\Application - */ - public function createApplication() - { - $app = require __DIR__.'/../bootstrap/app.php'; - - $app->make('Illuminate\Contracts\Console\Kernel')->bootstrap(); - - return $app; - } -}