Comments (5)
Hello Max, thanks for kind words.
What you expect is the default behavior of the Symfony application and has nothing in common with this library. If it is affecting dev
database it means, depending on Symfony version, that either you didn't have test database configured in config files or DATABASE_URL
env has been configured in dev mode.
I hope this will help you ;)
from apitestcase.
You put me to the right point. I have a local ENV Variable that was pointing to my dev database.
But after removing this env var it does not work either.
When i run the tests now, the database connection params are all filled with default values
In ApiTestCase.php on Line 106:
var_dump($this->entityManager->getConnection());
gives me this:
...
private $_params =>
array(11) {
'driver' =>
string(9) "pdo_mysql"
'charset' =>
string(7) "utf8mb4"
'url' =>
string(0) ""
'host' =>
string(9) "localhost"
'port' =>
NULL
'user' =>
string(4) "root"
'password' =>
NULL
'driverOptions' =>
array(0) {
}
'serverVersion' =>
string(3) "5.7"
'defaultTableOptions' =>
array(2) {
'charset' =>
string(7) "utf8mb4"
'collate' =>
string(18) "utf8mb4_unicode_ci"
}
'dbname' =>
string(0) ""
}
...
although i have defined this in my test/doctrine.yaml
doctrine:
dbal:
url: 'mysql://project_user:project_pass@mariadb:3306/project_int'
and this is my phpunit.xml.dist
under <php>
<ini name="error_reporting" value="-1" />
<env name="KERNEL_CLASS" value="App\Kernel" />
<env name="APP_ENV" value="test" />
<env name="APP_DEBUG" value="1" />
<env name="APP_SECRET" value="s$cretf0rt3st" />
<env name="SHELL_VERBOSITY" value="-1" />
<env name="SYMFONY_PHPUNIT_VERSION" value="7.4.3" />
<!--<env name="DATABASE_URL" value="mysql://premium_user:premium_pass@mariadb:3306/premium_int" />-->
<server name="FIXTURES_DIR" value="../tests/fixtures" />
<server name="IS_DOCTRINE_ORM_SUPPORTED" value="true" />
I can only run my tests with valid database settings, when i remove the comments from DATABASE_URL in phpunit.xml.dist
Any ideas , why the doctrine.yaml in my test folder is ignored?
from apitestcase.
You may be right, that <!--<env name="DATABASE_URL" value="mysql://premium_user:premium_pass@mariadb:3306/premium_int" />-->
may override config. Should be documented.
from apitestcase.
I found out that APP_ENV in phpunit.xml.dist is not interpreted in all cases. Especially when you run you code on docker it can happen, that env variables that are stored in the php-container cannot be overwritten by code.
So setting DATABASE_URL in phpunit.xml.dist is one way to go.
Another is documented here:
symfony/flex#251 (comment)
from apitestcase.
So I would consider it as solved
from apitestcase.
Related Issues (20)
- Symfony 4.1 update - Error HOT 4
- Use JsonApiTestCase assertions in behat HOT 3
- [Content-Type] application/problem+json HOT 2
- Status of this project HOT 6
- make PolishSymfonyCommunity/SymfonyMockerContainer optional HOT 2
- phpunit/phpunit as a dependency is discouraged
- Bug in ApiTestCase __construct() function
- The shared kernel does not parse the configuration files
- Symfony's KernelTestCase & WebTestCase forks HOT 1
- Support for PHPUnit 8 HOT 6
- Too much false positives in diffs HOT 12
- Replace assertContains with assertStringContainsString HOT 1
- PHPUnit constructor deprecation HOT 4
- Support for PHP 8.0 HOT 4
- Switch from Travis CI to GitHub Actions HOT 1
- The service "nelmio_alice.property_accessor.std" has a dependency on a non-existent service "property_accessor". HOT 3
- Cannot install symfony/maker-bundle because of doctrine/orm conflict
- New changes brakes data provider HOT 1
- Depreciation notices when running tests
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apitestcase.