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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$ php codecept.phar generate:test unit "./foo" causes <?php namespace .; #5818

Closed
mipon opened this issue Jan 16, 2020 · 0 comments · Fixed by #6070
Closed

$ php codecept.phar generate:test unit "./foo" causes <?php namespace .; #5818

mipon opened this issue Jan 16, 2020 · 0 comments · Fixed by #6070

Comments

@mipon
Copy link

mipon commented Jan 16, 2020

What are you trying to achieve?

Automate creating a test file using the generate:{suite/test} command, synched with IDE when a file is added/modified.

In this scenario, sometimes calculated relative path for the generating test file contains a dot. In that case, an invalid syntax is inserted in the resulting generated test file.

Passing a relative path is useful to keep a synchronized structure with the source directory. For example, passing "foo/bar" creates a test file unit/foo/barTest.php. This is great.

$ php codecept.phar generate:test unit "foo/bar"

However, when it contains a dot, like

$ php codecept.phar generate:test unit "./foo"

it creates a file fooTest.php with an invalid namespace syntax. The dot something passed by IDE.

What do you get instead?

A namespace with a dot gets inserted at the beginning of the generated file, which is invalid syntax and causes a fatal error. So it must be manually removed.

<?php namespace .;

class fooTest extends \Codeception\Test\Unit
{
    /**
     * @var \UnitTester
     */
    protected $tester;
    ...

Details

  • Codeception version: 4.0.1 (I downloaded it from the 4.0.2 link but it says 4.0.1)
  • PHP Version: 7.3
  • Operating System: Windows 10
  • Installation type: Phar
  • Suite configuration:
actor: UnitTester
modules:
    enabled:
        - Asserts
        - \Helper\Unit
    step_decorators: ~
error_level: "E_ALL ^ E_NOTICE"
bootstrap: _bootstrap.php
Naktibalda added a commit that referenced this issue Jan 2, 2021
When someone pass path as a class name, e.g. ./foo

Fixes #5818
Naktibalda added a commit that referenced this issue Jan 2, 2021
When someone pass path as a class name, e.g. ./foo

Fixes #5818
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 a pull request may close this issue.

1 participant