So, I am writing a basic Laravel package, and I seem to have stumbled upon another problem, this time with testing.
Currently, a package in development is located in the packages folder in the root of the project. I modified the composer.json file of the package to include the dependencies I need
"require-dev": { "phpunit/phpunit": "~4.0", "laravel/laravel": "dev-develop" }
However, when I try to run phpunit tests in a package folder (which contains a folder called tests along with a test sample), I get the following error:
PHP Fatal error: class 'Illuminate \ Foundation \ Testing \ TestCase' not found in / workspace / laravel / packages / sample / http -request / tests / HttpRequestTest.php on line 8
The test file is just a stub automatically generated:
<?php use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; class HttpRequestTest extends Illuminate\Foundation\Testing\TestCase { public function testExample() { $this->assertTrue(true); } }
Any idea why this is not working? Application tests run smoothly, but the application itself has no dependencies other than what is in the field.
Decision
I managed to get it working independently by expanding PHPUnit_Framework_TestCase:
class HttpRequestTest extends PHPUnit_Framework_TestCase
However, by running it like this:
vendor/bin/phpunit packages/yourname/package-name/
It also works, so I chose it as the answer.