-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with setting header in symfony #125
Comments
@mfratczak fastes just parallelize them: if you set header and/or cookie in the "standard" way (e.g.: for behat in a |
@DonCallisto can you please share your snippet of the BeforeScenario method and how you implement the different database names? |
@mfratczak, @OskarStark we do something like
|
Nice an are you using mysql or SQLite for test? And how do you replace the dB name then? |
@liuggio did you think about a behat context which could be enabled and provide the cookie stuff by @DonCallisto ? |
@OskarStark Right now we're using SQLite for tests and MySQL for real env. I know, it kinda sucks because we cannot reproduce the real stack but ATM we never had troubles with this. As our infrastructure is huge we never switched but we should sooner or later. BTW @liuggio don't follow this project anymore AFAIK and I really don't think this kind of Context should be something that fastest should care about. TBH all behat things should live into an extension but for the moment that's not a big deal for the project to keep them internal. WDYT? |
Hey @DonCallisto I try something like this with Symfony 4.1: // The check is to ensure we don't use .env in production
if (!isset($_SERVER['APP_ENV'])) {
if (!class_exists(Dotenv::class)) {
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
}
(new Dotenv())->load(__DIR__.'/../.env');
}
FastestEnvironment::setFromRequest();
$testDatabaseUrl = str_replace('luna', getenv('ENV_TEST_CHANNEL_READABLE'), getenv('DATABASE_URL'));
putenv("DATABASE_URL=$testDatabaseUrl"); but I execute it like this: And added this to my FeatureContext: /**
* @BeforeScenario
*/
public function addFastestChannelInformation()
{
if (getenv('ENV_TEST_CHANNEL_READABLE')) {
$this->minkContext->getSession()->setCookie('ENV_TEST_CHANNEL_READABLE', getenv('ENV_TEST_CHANNEL_READABLE'));
}
} Regarding the context, I think we could make it quite simple for people to start by registering the context, of read this issue 😄 Creating |
Well, I have a quite complex setup as we use doctrine sharding so this is little bit more complicated and right now I can't take a look and get rid in a safe way of all those concept and post something that surely work (as I should take time to get rid of all sharding concepts and then test that's fine). I suppose that
is resolved with the link I've provided to you |
Ah i overlooked that, but link, thank you! But now I got this error: are you sure this works with Sf4 ? this is the failing code in public function createConnection(array $params, Configuration $config = null, EventManager $eventManager = null, array $mappingTypes = [])
{
if (isset($params['dbname'])) {
$dbName = $this->getDbNameFromEnv($params['dbname']);
} else {
$dbName = $this->getDbNameFromEnv($params['master']['dbname']);
} |
Not sure that's a symfony problem as those data should came from DBAL, as this connection is used by that layer. |
However this project should have nothing to do with symfony (apart for direct deps used in the code), maybe we should write a kind of "normalizer" to be sure to accept those parameters in the same format regardless how they're declared inside config files. |
@OskarStark I resolved this with custom bootstrap with phpunit and a small configuration change: doctrine:
dbal:
url: '%env(DATABASE_URL)%'
# This is needed for 'fastest' see https://github.com/liuggio/fastest/issues/101
dbname: '%env(DATABASE_NAME)' ###> doctrine/doctrine-bundle ###
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls
DATABASE_NAME=symfony
DATABASE_URL=mysql://[email protected]:3306/${DATABASE_NAME}?charset=utf8mb4&serverVersion=mariadb-10.2.14
###< doctrine/doctrine-bundle ### |
@tarlepp thank your for your feedback, I got it almost working 🙏
the name is routed through the test scope, but the database is not created. |
Ah I found this in your repo: Is this everything I need todo? |
@OskarStark that is how I got that working, there might be some parts you don't need though. One important thing is also in |
I got it working and here are my behat contexts I use. https://gist.github.com/OskarStark/5a3ce2bab27998a32a458377650abaa2 @tarlepp instead of executing the database commands via doctrine, I will try to get it working, but not sure if this is executed in the bootsraped environment 🤔 |
The funny thing is, that my suite takes
|
How many process did you use for consumption? |
That's weird ... |
weird with that speed, in my case I get following; But in earlier I noticed that fastest will impact |
@DonCallisto
with the code
have no idea why. any suggestions? also, I have tried to set header with the code
and it gives me error
Symfony 3.4. latest Behat and Mink. |
Or any idea how to attach GET parameter to all requests with Symfony Behat Mink? |
@seyfer that's not a fastest issue, btw you can search for a solution on the web or open a issue at Selenium repository. AFAIK, before setting a cookie you should start navigate at least one page of the domain. For example, before that set, we do something like
That is not related to fastest but is useful when you need to set a debug key (and I suppose that consequently we are able to set the cookie). |
Do you run Selenium in Hub mode with several browser instances? If not, it gives no benefit as processes wait for one browser instance to be available. |
I'm closing it as it's not a fastest issue and the converstation seems to be over. |
Hi,
I have use opensoure sylius ecommerce system, and i want use fastest. But we use selenium or local server to test (using behat). How i can put header or cookie on start to every test? i dont want change every test. I'm trying this more than 4 days, and still have problem :)
The text was updated successfully, but these errors were encountered: