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

InjectionException doesn"t reflect real Error (PHP 7) #3869

Closed
timtkachenko opened this issue Dec 23, 2016 · 2 comments
Closed

InjectionException doesn"t reflect real Error (PHP 7) #3869

timtkachenko opened this issue Dec 23, 2016 · 2 comments
Labels

Comments

@timtkachenko
Copy link

What are you trying to achieve?

I"d like to see correct error/exceptions that will be clear.

PHPUnit_Framework_Exception: Declaration of Step\Functional\Bar::make($name) should be compatible with Step\Functional\Base::make($name = NULL)
/srv/test/tests/_support/Step/Functional/Bar.php:4

What do you get instead?

currently I get

[InjectionException] Failed to inject dependencies in instance of "FooCest". Class Step\Functional\Bar does not exist

doesn"t reflect real Error

Provide console output if related. Use -vvv mode for more details.

./codecept run functional --debug -vvv

# paste output here

Codeception PHP Testing Framework v2.2.7
Powered by PHPUnit 5.7.4 by Sebastian Bergmann and contributors.

Functional Tests (1) --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Modules: \Helper\Functional
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FooCest: Try to test
Signature: FooCest:tryToTest
Test: tests/functional/FooCest.php:tryToTest
Scenario --
 ERROR 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Time: 72 ms, Memory: 8.00MB

There was 1 error:

---------
1) FooCest: Try to test
 Test  tests/functional/FooCest.php:tryToTest
                                                                                                                         
  [InjectionException] Failed to inject dependencies in instance of "FooCest". Class Step\Functional\Bar does not exist  
                                                                                                                         

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

Provide test source code if related
generate ./codecept generate:stepobject functional Base

namespace Step\Functional;

class Base extends \FunctionalTester
{

	public function make($name = null)
	{
		$I = $this;
	}

}

extend with incorect signature

// paste test
namespace Step\Functional;

class Bar extends Base
{

    public function make($name)
    {
        $I = $this;
    }

}

Details

  • Codeception version:
    Codeception PHP Testing Framework v2.2.7
  • PHP Version: 7.*
  • Operating System: ubuntu 16
  • Installation type:Composer
  • List of installed packages (composer show) irrelevant
  • Suite configuration:
# paste suite config here
default

potential fix

codeception/codeception/src/Codeception/Lib/Di.php

public function injectDependencies
...
        try {
            $args = $this->prepareArgs($reflectedMethod, $defaults);
        } catch (\Exception $e) {
                // lines [115 ... 121]
		$msg = $e->getMessage();
		if($e->getPrevious()){
			$msg .= "; ". $e->getPrevious();
		}
            throw new InjectionException(
                "Failed to inject dependencies in instance of "{$reflectedObject->name}". " . $msg
            );
        }
...
@DavertMik DavertMik added the Bug label Dec 23, 2016
@DavertMik
Copy link
Member

Thanks for the detailed report

@Naktibalda
Copy link
Member

@timtkachenko Please make a pull request.

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

No branches or pull requests

3 participants