Closed Drenth1 closed 1 year ago
When I run my tests for my Laravel package using ./vendor/bin/phpunit tests --testdox I get the following error:
./vendor/bin/phpunit tests --testdox
Illuminate\Contracts\Container\BindingResolutionException: Target class [cache.store] does not exist.
Create a BaseTestCase that extends the \Orchestra\Testbench\TestCase testcase
\Orchestra\Testbench\TestCase
class BaseTestCase extends \Orchestra\Testbench\TestCase { public function setUp() : void { parent::setUp(); // the line that throws the error } protected function getApplicationProviders($app) : array { return [ MyApplicationKernelServiceProvider::class ]; } protected function getEnvironmentSetUp($app) : void { $app['config']->set('database.default', 'testing'); $app['config']->set('database.connections.testing', [ 'driver' => 'sqlite', 'database' => ':memory:', 'prefix' => '', ]); } }
Create a testcase that extends the BaseTestCase and add a simple assertion
class BaseTest extends BaseTestCase { public function test_we_can_run_tests() : void { $this->assertTrue(true); } }
parent::setUp();
getEnvironmentSetup()
getApplicationProviders()
phpunit.xml
<?xml version="1.0" encoding="UTF-8"?> <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"> <coverage> <include> <directory suffix=".php">src/</directory> </include> </coverage> <testsuites> <testsuite name="Unit"> <directory suffix="Test.php">./tests/Unit</directory> </testsuite> <testsuite name="Feature"> <directory suffix="Test.php">./tests/Feature</directory> </testsuite> </testsuites> <php> <env name="DB_CONNECTION" value="testing"/> <env name="APP_KEY" value="<removed>"/> </php> </phpunit>
Description:
When I run my tests for my Laravel package using
./vendor/bin/phpunit tests --testdox
I get the following error:Steps To Reproduce:
Create a BaseTestCase that extends the
\Orchestra\Testbench\TestCase
testcaseCreate a testcase that extends the BaseTestCase and add a simple assertion
./vendor/bin/phpunit tests --testdox
Additional information
parent::setUp();
, the test runs normally.getEnvironmentSetup()
,getApplicationProviders()
or both, the error remains the same.phpunit.xml
configuration: