Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

3.0 phpunit #1355

Merged
merged 29 commits into from

4 participants

@lorenzo
Owner

This is my humble approach to not using the test shell for running core tests. I had several goals in mind

  • Not depend on any App folder configuration
  • Not mess with phpunit internals by overriding classes
  • Be able to just type phpunit to run all test so that we can add groups later
  • Have a clean way to pass env variables and use them in the phpunit init script

I also made some broken tests pass during the process. There might be some problems with sqlite and postgres, but they are due to unimplemented/broken features in the database layer.

lorenzo added some commits
@markstory
Owner

I'd love to not have the test shell at all. Ideally each app/plugin could include a phpunit.xml, and Test/bootstrap.php file to setup PHPUnit. We could generate these file as part of baking new plugins/apps. I think the test shell doesn't really contribute enough to make it worth carrying forwards.

I'm a big :+1: on the general idea.

@markstory markstory commented on the diff
lib/Cake/Test/init.php
((73 lines not shown))
+]);
+
+Cake\Core\Configure::write('Log.debug', [
+ 'engine' => 'Cake\Log\Engine\FileLog',
+ 'levels' => ['notice', 'info', 'debug'],
+ 'file' => 'debug',
+]);
+
+Cake\Core\Configure::write('Log.error', [
+ 'engine' => 'Cake\Log\Engine\FileLog',
+ 'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
+ 'file' => 'error',
+]);
+
+$autoloader = new Cake\Core\ClassLoader('TestApp', dirname(__DIR__) . '/Test');
+$autoloader->register();
@markstory Owner

You could use the classes to method calls shorter.

@lorenzo Owner
lorenzo added a note

sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@markstory markstory commented on the diff
lib/Cake/Test/init.php
((70 lines not shown))
+
+Cake\Core\Configure::write('Session', [
+ 'defaults' => 'php'
+]);
+
+Cake\Core\Configure::write('Log.debug', [
+ 'engine' => 'Cake\Log\Engine\FileLog',
+ 'levels' => ['notice', 'info', 'debug'],
+ 'file' => 'debug',
+]);
+
+Cake\Core\Configure::write('Log.error', [
+ 'engine' => 'Cake\Log\Engine\FileLog',
+ 'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
+ 'file' => 'error',
+]);
@markstory Owner

It would be nice if the core test logs didn't modify the app logs. Perhaps use sys_get_temp_dir() instead?

@lorenzo Owner
lorenzo added a note

That was my first attempt and failed miserably. I can give it a second try, though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@markstory markstory commented on the diff
lib/Cake/TestSuite/Fixture/FixtureInjector.php
((16 lines not shown))
+ */
+namespace Cake\TestSuite\Fixture;
+
+use \Exception;
+use \Cake\TestSuite\TestCase;
+use \Cake\TestSuite\Fixture\FixtureManager;
+use \PHPUnit_Framework_AssertionFailedError;
+use \PHPUnit_Framework_Test;
+use \PHPUnit_Framework_TestSuite;
+use \PHPUnit_Framework_TestListener;
+
+/**
+ * Test listener used to inject a fixture manager in all tests that
+ * are composed inside a Test Suite
+ */
+class FixtureInjector implements \PHPUnit_Framework_TestListener {
@markstory Owner

Yay!

@markstory Owner

I wonder if there is a way to update the TestShell so we can re-use this. That might make it easier to override fewer PHPUnit internals.

@lorenzo Owner
lorenzo added a note

I will do that

@lorenzo Owner
lorenzo added a note

I think it will require some changes that I'm not sure they are worth doing now. I'd like to just use phpunit for the app too, so there would not be much gain from changing stuff now that we are going to remove soon.

@markstory Owner

Fair enough. Do you think that changing to using phpunit for app/plugin tests is going to be a big shock for our developers? It might mean the end of the webrunner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/Cake/phpunit.xml.dist
((6 lines not shown))
+ stopOnFailure="false"
+ syntaxCheck="false"
+ bootstrap="./Test/init.php"
+ >
+ <php>
+ <ini name="memory_limit" value="-1"/>
+ <ini name="apc.enable_cli" value="1"/>
+ </php>
+
+ <testsuites>
+ <testsuite name="CakePHP Test Suite">
+ <directory>./Test/TestCase/</directory>
+ <exclude>./Test/TestCase/Model/</exclude>
+ <exclude>./Test/TestCase/Network/Email</exclude>
+ <exclude>./Test/TestCase/Network/SocketTest.php</exclude>
+ <exclude>./Test/TestCase/Error/ErrorHandlerTest.php</exclude>
@markstory Owner

Why are the Email, Socket and ErrorHandler tests excluded?

@lorenzo Owner
lorenzo added a note

All the Network folder was skipped for 3.0 (including Request and Response Tests) Those tests seem very broken right now, I will remove this line and make the tests incomplete or something

@markstory Owner

Interesting the request/response tests were passing at one point, as were the http/client tests. I'll take a look at the failing tests in Socket/Email and see if I can get them working.

@markstory Owner

I only get one local error due to SMTP server issues. All the other tests in the AllNetwork suite are passing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@renan
Collaborator

No more cross database tests?

The ORM layer doesn't support it yet.

@lorenzo
Owner

@renansaddam We don't have those yet

@markstory
Owner

I've fixed the sqlite tests on 3.0. Creating new connections on every test method was causing issues with memory databases.

@lorenzo
Owner

Can this be merged now?

@markstory
Owner

I think so, we should probably discuss removing the test shell and only using phpunit on the cakephp-core mailing list.

@lorenzo
Owner

I will send an email today

@lorenzo lorenzo merged commit 0cb0d36 into cakephp:3.0

1 check failed

Details default The Travis CI build failed
@lorenzo lorenzo deleted the unknown repository branch
@AD7six
Collaborator

Be able to just type phpunit to run all test

Belated: yay, :+1: to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 13, 2013
  1. @lorenzo
Commits on Jun 14, 2013
  1. @lorenzo

    Removing test suites, adding some exceptions in the xml as the tests are

    lorenzo authored
    completely broken right now. Small tweaks to make other test pass
  2. @lorenzo
  3. @lorenzo
Commits on Jun 15, 2013
  1. @lorenzo

    Fixied failing test

    lorenzo authored
  2. @lorenzo
Commits on Jun 16, 2013
  1. @lorenzo
  2. @lorenzo

    Fixing faulty test

    lorenzo authored
  3. @lorenzo
  4. @lorenzo

    Removing AllORMTest

    lorenzo authored
  5. @lorenzo
  6. @lorenzo

    Fixing a couple broken tests

    lorenzo authored
  7. @lorenzo
  8. @lorenzo
  9. @lorenzo

    Fixing travis script command

    lorenzo authored
  10. @lorenzo
  11. @lorenzo
  12. @lorenzo

    Fixing namespace in test

    lorenzo authored
  13. @lorenzo
  14. @lorenzo
  15. @lorenzo
  16. @lorenzo
  17. @lorenzo
  18. @lorenzo
Commits on Jun 17, 2013
  1. @lorenzo

    Merge remote-tracking branch 'origin/3.0' into 3.0-phpunit

    lorenzo authored
    Conflicts:
    	lib/Cake/Test/TestCase/ORM/QueryTest.php
    	lib/Cake/Test/TestCase/ORM/TableTest.php
  2. @lorenzo
  3. @lorenzo
Commits on Jun 18, 2013
  1. @lorenzo
  2. @lorenzo
Something went wrong with that request. Please try again.