Hello team, I have just started implementing a tes...
# pact-php
s
Hello team, I have just started implementing a test case using pact-php and i am facing an issue where the consumer repo is a consumer to 3 API . So i plan on creating 3 test case files (one for each provider) and i want to set the provider name for each api . So far i dont see how can i do that . I am setting
PACT_PROVIDER_NAME
from the environment file (in my case i am running the consumer inside a docker container so a .env file) . I tried using below code in the test itself but its not overwriting the environment variable.
Copy code
putenv("PACT_PROVIDER_NAME=some-api");
I am using
MockServerEnvConfig()
to get the configurations. Can someone explain how can we do it ?
m
in that case, don’t use the
EnvConfig
version, and then you can use
$config->setProvider('someProvider');
Does that not work for you?
(I haven’t tried this, but the docs suggest it)
s
alright yea that works for me . So in this case i have to start the server manually which is not a problem. I can extract out this config in a function which i will need to call in every test as a
before
condition. I am thinking about stopping the server when a exception is thrown from test
👍 1