Comments (7)
Hi @lsv
I think you can leverage global state here.
I have a similar problem: I need some sql views to be created in order to be used in the tests.
I'm using an invokable service to generate them:
// /config/packages/zenstruck_foundry.php
$containerConfigurator->extension('zenstruck_foundry', [
'global_state' => [
ViewsGenerator::class,
],
]);
and it gets created before each test (actually, before the very first test of the suite, since I'm using dama)
from foundry.
Thank you @nikophil for your answer and the tip,
But I think the @lsv issue and the mine 😄 is that createSchema
method will fail if we haven't enabled PostGIS extension.
The extension offers a set of functions and types that are used to generate our tables.
global_state
is a bit too late.
// vendor/zenstruck/foundry/src/Test/ORMDatabaseResetter.php
final class ORMDatabaseResetter extends AbstractSchemaResetter
{
// ....
public function resetDatabase(): void
{
$this->dropAndResetDatabase();
// we need to make this sql query here 'CREATE EXTENSION postgis';
// because our schema contain PostGIS functions
$this->createSchema();
}
// ....
}
Dama couldn't help us either because resetDatabase
seems to be called in the beforeClassMethod
.
from foundry.
Hi @lhapaipai
indeed, you're right!
Maybe you could enable migrate
mode for the database resetter?
You can look at this issue: #477
This comes with a performance cost, which makes dama almost mandatory.
(it was exactly the same problem, and I gave exactly the same wrong answer 🤡 )
from foundry.
Thank you @nikophil , I imagine this comes with performance cost, but at least it solves the problem !!
from foundry.
If you use dama, the performance cost is really limited, since the migrations are only ran once.
Maybe this whole problem could be solved by introducing some kind of events in the database creation process
WDYT @kbond ?
from foundry.
ok,
I think it could be super useful 😄 !!
from foundry.
WDYT @kbond ?
Yeah, I feel like this makes sense. I believe we've hardcoded out own platform-specific logic to the reset database process. These could perhaps be moved to events also.
from foundry.
Related Issues (20)
- Force set attribute HOT 4
- Configuration instantiates faker generator prematurely HOT 3
- Creating linked entities dependent on parent entity HOT 2
- Unrecognized option "make_story" under "zenstruck_foundry" HOT 3
- `make:factory` fails when there is more than one level of embedded classes HOT 2
- Named `FactoryCollection` constructors don't have proper type declarations HOT 2
- Performance Problem with random HOT 3
- Doctrine embeddables with v2 HOT 8
- [Tests] use 2 schemas in the same database
- Migration Guide to version 2 HOT 3
- V2 and phpstan HOT 5
- Upgrade from 1.37 to 1.38 introduce a memory leak HOT 13
- H
- [2.x] ArgumentCountError thrown when passing $attributes array to closure in event HOT 9
- Creation of dynamic property App\Entity\MyEntity::$_autoRefresh is deprecated HOT 6
- Issue with Proxy Entities in Version 2 HOT 14
- Zenstruck\Foundry\Factory::$class must not be accessed before initialization HOT 6
- Find functions do not refresh entity
- Attribute wrapped in a Foundry Proxy is not compatible with `Symfony\Component\VarExporter\LazyProxyTrait` HOT 4
- Foundry should not remove symfony-s errorHandlers HOT 6
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 foundry.