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

For tests that have and use a DI container, allow test cases to be injected #8815

Closed
diosmosis opened this issue Sep 17, 2015 · 0 comments
Closed
Labels
c: Tests & QA For issues related to automated tests or making it easier to QA & test issues. wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.

Comments

@diosmosis
Copy link
Member

Currently in tests that use a DI container, if we want to get an object from the container, it's necessary to find the Piwik Environment instance, and manually get and use the DI container. Instead of this work, however, we could make it possible to inject the test cases themselves w/ the objects to test.

For example, this:

class SegmentQueryDecoratorTest extends IntegrationTestCase
{
    public function setUp()
    {
        parent::setUp();
        $this->segmentQueryDecorator = self::$fixture->piwikEnvironment->getContainer()->get('Piwik\Plugins\SegmentEditor\SegmentQueryDecorator');
    }

    // ...
}

would become:

class SegmentQueryDecoratorTest extends IntegrationTestCase
{
    /**
      * @Inject
      * @var SegmentQueryDecorator
      */
    private $segmentQueryDecorator;

    // ...
}

Note: This would only affect integration & system test cases. The DI container should not be used in unit tests.

@diosmosis diosmosis added the c: Tests & QA For issues related to automated tests or making it easier to QA & test issues. label Sep 17, 2015
@diosmosis diosmosis added this to the 3.0.0 milestone Sep 17, 2015
@mattab mattab closed this as completed Jul 8, 2016
@mattab mattab added the wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it. label Jul 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Tests & QA For issues related to automated tests or making it easier to QA & test issues. wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.
Projects
None yet
Development

No branches or pull requests

2 participants