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

[RFC] Proposal for namespaced class unit tests #16761

Closed
wants to merge 1 commit into from
Closed

[RFC] Proposal for namespaced class unit tests #16761

wants to merge 1 commit into from

Conversation

mbabker
Copy link
Contributor

@mbabker mbabker commented Jun 19, 2017

Summary of Changes

With all of the class namespacing going on, we don't really have a procedure in place for adding unit tests for new namespaced classes. Luckily this isn't a problem within 3.x right now, but in 4.0 we have added a bunch of classes and right now they have zero test coverage.

With the introduction of Codeception for other test types, we can look at ways to make use of it for addressing this issue. And since Codeception can run PHPUnit tests, there should be no tooling conflicts.

My first draft of this moves the test class for the former JErrorPage, now Joomla\CMS\Exception\ExceptionHandler, into the Codeception unit test space. The convention I've used thus far is to use a root cms directory which would basically be the equivalent of 3.8's libraries/src/Joomla/CMS directory then the tests would follow the same structure we have now (the file/folder mapping closely matches up to the production system).

I've added arbitrary autoloader support as well using the Joomla\CMS\Tests namespace. So in places where we're requiring stub classes, they now have an autoloader mapping.

@rdeutz
Copy link
Contributor

rdeutz commented Jun 19, 2017

Can you have a look here #16743 if this works together?

@mbabker
Copy link
Contributor Author

mbabker commented Jun 19, 2017

It should. The only possible incompatibility right now is I put the dev autoload statement in the root Composer manifest versus the Codeception Composer manifest (I'm not quite sure why we need that one but let's roll with it for now). In theory both libraries/vendor/bin/phpunit --testsuite libraries and tests/codeception/vendor/bin/codecept run unit should run the same tests with this, but since I haven't set up the unit test bootstrap in Codeception the latter command won't work right now.

@mbabker
Copy link
Contributor Author

mbabker commented Jul 1, 2017

This is at a point now where running both libraries/vendor/bin/phpunit --testsuite libraries and tests/codeception/vendor/bin/codecept run unit can work for running the tests for this class. The Codeception unit test suite's bootstrap is just mimicking the PHPUnit suite's bootstrap for now to get everything imported, we can work out shuffling some of the helper resources around later.

@rdeutz rdeutz self-assigned this Jul 29, 2017
@mbabker mbabker changed the base branch from 3.8-dev to staging August 20, 2017 18:25
@mbabker mbabker closed this Mar 31, 2018
@mbabker mbabker deleted the namespace-test branch March 31, 2018 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants