Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create the _generated folder before writing a .gitignore file there #4449

Conversation

nstapelbroek
Copy link

@nstapelbroek nstapelbroek commented Aug 14, 2017

Hi there 馃憢

After following the setup guide on a fresh project I got hit with a warning:

$ ./vendor/bin/codecept init api
Let's prepare Codeception for REST API testing

? Where tests will be stored? (tests) 
? Start url for tests (http://localhost/api) 
PHP Warning:  file_put_contents(tests/_support/_generated/.gitignore): failed to open stream: No such file or directory in /home/nico/Projects/myawesomeproject/vendor/codeception/codeception/src/Codeception/InitTemplate.php on line 204
> Created test directories inside at tests
> Api helper has been created in tests/_support/Helper
> ApiTester actor has been created in tests/_support
> Actions have been loaded
> Created global config codeception.yml inside the root directory
> Created a demo test ApiCest.php

 INSTALLATION COMPLETE 

Next steps:
1. Edit tests/ApiCest.php to write first API tests
2. Run tests using: codecept run

Happy testing!

To prevent this error, I came up with two solutions:

  1. Create the directory before it exists
  2. Patch thegitIgnore() method so it checks if the path exists before writing the file.

Approach 2 seemed more ideal but might break other logic since I don't know why the statement in https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/InitTemplate.php#L203 exists. Why is it testing if we have a .gitignore in our project root? To prevent confusion I've picked solution 1.

I'd love to know if you have any feedback on the PR. Thanks for Codeception 馃殌

@Naktibalda
Copy link
Member

Thanks, this solution is good enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants