Invalid path to test files running Codeception in Vagrant in PHPStorm

Hi,

I have the following stack:

  • Windows 10
  • Vagrant running Homestead box (Ubuntu 18.04)

My Windows doesn't even have PHP installed. Everything is installed in the vagrant machine.

I use PHPStorm in Windows, and I have the following settings:

 

CLI Interpreter:

 

All of my projects are under C:/Vagrant/dev, so I have this Path Mappings:

 

Then, at Languages & Frameworks -> PHP -> Test Frameworks, I have this Codeception config:

However, when I try to run a test with test scope Method (Ctrl+Shift+F10), it can't find the file:

 

When I go to edit the configurations:

 

It is trying to use Windows path:

 

And if I try to set vagrant path there, it says my path is invalid:


So that's it, I'm lost here.

Can anyone help me?

Thanks!

5 comments

Do I get right that C:\Vagrant\dev is not the root of the current project? If so, please try setting the local path to the project root, and amend the remote path accordingly.

0

Hi Eugene,

Thanks for your reply.

Adding project path didn't help:

Got this error:

```
Testing started at 23:15 ...
ssh://vagrant@127.0.0.1:22/usr/bin/php /home/vagrant/.phpstorm_helpers/codeception.php run --report -o "reporters: report: PhpStorm_Codeception_ReportPrinter" --no-ansi --no-interaction -c /home/vagrant/dev/code/cfpp/wp-content/plugins/woo-correios-calculo-de-frete-na-pagina-do-produto/codeception.dist.yml wp-content/plugins/woo-correios-calculo-de-frete-na-pagina-do-produto/tests/functional/rest/AjaxRequestCest.php
Codeception PHP Testing Framework v2.4.5
Powered by PHPUnit 7.4.3 by Sebastian Bergmann and contributors.

In Run.php line 370:

Suite 'wp-content/plugins/woo-correios-calculo-de-frete-na-pagina-do-produt
o/tests/functional/rest/AjaxRequestCest.php' could not be found
```

The root of the problem seems to be that .phpstorm_helpers is using a relative path instead of an absolute, don't you agree?

0

don't you agree?

It makes sense, but I replicated your setup and it works just fine: http://prntscr.com/lietzg

Note the Vagrant folder being different from the project root, and the path still being relative to the project root. PhpStorm handles that.

My mappings idea also failed to be confirmed, I went ahead with default mappings and it was OK.

I think it may have relation to the configuration file you're using.

Please try:

  1. Running the test with no configuration file set for Codeception in PhpStorm.
  2. Running the test manually in the Vagrant:
    • cd /home/vagrant/dev/code/cfpp
    • $path-to-codecept$ run -c wp-content/plugins/woo-correios-calculo-de-frete-na-pagina-do-produto/codeception.dist.yml wp-content/plugins/woo-correios-calculo-de-frete-na-pagina-do-produto/tests/functional/rest/AjaxRequestCest.php
    • And the same command with no -c specified.
0

Hi Eugene,

1 . Running the test with no configuration file set for Codeception in PhpStorm.

Testing started at 22:15 ...
ssh://vagrant@127.0.0.1:22/usr/bin/php /home/vagrant/.phpstorm_helpers/codeception.php run --report -o "reporters: report: PhpStorm_Codeception_ReportPrinter" --no-ansi --no-interaction wp-content/plugins/woo-correios-calculo-de-frete-na-pagina-do-produto/tests/functional/ajax/ValidationCest.php:should_fail_if_empty_data

In Configuration.php line 159:

Configuration file could not be found.
Run `bootstrap` to initialize Codeception.

 

Running the test manually in the Vagrant with -c:

vagrant@homestead:~/dev/code/cfpp$ wp-content/plugins/woo-correios-calculo-de-frete-na-pagina-do-produto/vendor/bin/codecept run -c wp-content/plugins/woo-correios-calculo-de-frete-na-pagina-do-produto/codeception.dist.yml wp-content/plugins/woo-correios-calculo-de-frete-na-pagina-do-produto/tests/functional/ajax/ValidationCest.php
Codeception PHP Testing Framework v2.4.5
Powered by PHPUnit 7.4.3 by Sebastian Bergmann and contributors.

In Run.php line 370:

Suite 'wp-content/plugins/woo-correios-calculo-de-frete-na-pagina-do-produt
o/tests/functional/ajax/ValidationCest.php' could not be found

 

Running the test manually in the Vagrant without -c:

vagrant@homestead:~/dev/code/cfpp$ wp-content/plugins/woo-correios-calculo-de-frete-na-pagina-do-produto/vendor/bin/codecept run wp-content/plugins/woo-correios-calculo-de-frete-na-pagina-do-produto/tests/functional/ajax/ValidationCest.php
In Configuration.php line 159:

Configuration file could not be found.
Run `bootstrap` to initialize Codeception.

 

I tried both commands using full paths, got the same results.

This, however, works:

vagrant@homestead:~/dev/code/cfpp/wp-content/plugins/woo-correios-calculo-de-frete-na-pagina-do-produto$ codecept run functional ajax/ValidationCest.php

 

And this is what I'm currently using in PHPStorm that's working:

You see? I configure the test I want to run in Test Runner field. It's not great, but it works.

Testing it in Vagrant like that gives me more freedom to debug, this is starting to look more like an issue on my end than PHPStorm's, right?

 

0

Try setting up "Custom working directory" and point it to a root of your project that hosts /vendor/condecept. Should be C:/Vagrant/dev/code/cfpp/wp-content/plugins/woo-correios-calculo-de-frete-na-pagina-do-produto/ by the looks of it.

0

Please sign in to leave a comment.