wp-cli / scaffold-package-command

Scaffolds WP-CLI commands with functional tests, full README.md, and more.
MIT License
69 stars 20 forks source link

Test suite generated by `wp scaffold package-tests` has something problem #157

Closed miya0001 closed 6 years ago

miya0001 commented 6 years ago

When we create a command like following.

<?php

class Test_Command extends WP_CLI_Command {
    /**
     * Test command
     *
     * @when before_wp_load
     */
    public function example1() {
        $path = dirname( __FILE__ ) . '/path/to/file';
        WP_CLI::success( $path );
    }
}

I expect to get absolute path like following and it is working fine.

$ wp test example1
Success: /Users/miyauchi/wp-cli/test-command/src/path/to/file

But I run this command with behat, all path will be changed to relative path like following.

$ wp test example1
      Success: src/path/to/file

Same problem will be happen on my package command. https://github.com/vccw-team/wp-cli-scaffold-movefile/blob/499f401d817c65866602df66d920e250a4562ef1/src/Scaffold_Movefile_Command.php#L134

It is getting the path to *.mustache like following.

return dirname( dirname( __FILE__ ) ) . '/templates/movefile.mustache';

But it returns only templates/movefile.mustache. (Where is the first /???)

Are there any mistakes or any misunderstanding?

I committed an example command to reproduce this problem.

miya0001 commented 6 years ago

I ran behat for scaffold-command and I found there are some broken tests. I am not sure is it same problem. Following is a log. Terminal Saved Output.txt

miya0001 commented 6 years ago

Ah, I ran those tests after wp package update and wp scaffold package-tests . --force.

danielbachhuber commented 6 years ago

@miya0001 Is there a bug here or can this be closed?

miya0001 commented 6 years ago

I am looking into this problem, but I haven't found the cause. 😓 Do you have any idea?

danielbachhuber commented 6 years ago

No immediate ideas :/

miya0001 commented 6 years ago

Behat is removing the path to project root from output and I was making some mistakes. So, I was confusing, there is no problem. Thanks for help me. @gitlost @danielbachhuber

I can close this issue. Thanks! :)