Refactors test suite to run with vanilla PHPUnit runner#2
Refactors test suite to run with vanilla PHPUnit runner#2garethellis36 wants to merge 5 commits intomasterfrom
Conversation
| /** | ||
| * @var array|int[]|mixed | ||
| */ | ||
| private $_cacheDisable; |
There was a problem hiding this comment.
This property is added in a few test classes because I was getting warnings about it not being present before I had fixed the error-handling. It doesn't actually need to be there for the tests to pass but it also doesn't hurt to clean this up I guess.
|
|
||
| foreach ($servers as $server) { | ||
| list($host, $port) = explode(':', $server); | ||
| [$host, $port] = explode(':', $server); |
| public $records = array( | ||
| array('username' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'), | ||
| array('username' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31'), | ||
| array('username' => 'nate', 'password' => '5f4dcc3b5aa765d61Cakd8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31'), |
There was a problem hiding this comment.
I can't tell what changed here.
| $level = ob_get_level(); | ||
|
|
||
| if (!empty($this->fixtureManager)) { | ||
| $this->fixtureManager->load($this); |
There was a problem hiding this comment.
This stuff is now done in the setUp() method
| } | ||
| $result = parent::run($result); | ||
| if (!empty($this->fixtureManager)) { | ||
| $this->fixtureManager->unload($this); |
There was a problem hiding this comment.
This is now done in tearDown()
| } | ||
|
|
||
| for ($i = ob_get_level(); $i < $level; ++$i) { | ||
| ob_start(); |
There was a problem hiding this comment.
I don't know what this ob_* stuff was for, but deleting it doesn't break anything. Cake also has a browser test runner, so it might have been for that.
| * @param string $method Test method about that was executed. | ||
| * @return void | ||
| */ | ||
| public function endTest($method) { |
There was a problem hiding this comment.
These methods did literally nothing. They're not overriding a parent method or anything.
There was a problem hiding this comment.
They are there to be overridden aren't they? Like abstract methods but they don't need to be implemented.
|
|
||
| if (!empty($this->fixtures)) { | ||
| $this->fixtureManager = $this->fixtureManager ?? CakeFixtureManager::getInstance(); | ||
| $this->fixtureManager->fixturize($this); |
There was a problem hiding this comment.
The fixturize() step was done inside CakeTestRunner before. The fixturize() method has checks already in place to make sure it doesn't do duplicate work.
| * @param bool $reset to set new static timestamp. | ||
| * @return int timestamp | ||
| */ | ||
| public static function time($reset = false) { |
There was a problem hiding this comment.
This was previously in CakeTestSuiteDispatcher.
| parent::assertPostConditions(); | ||
| $this->endTest($this->getName()); | ||
| } | ||
|
|
There was a problem hiding this comment.
The parent methods of these did absolutely nothing. I guess they did something once upon a time!
There was a problem hiding this comment.
You are removing CakeTestCase functionality here but removing the 'startTest' and 'endTest' methods being called. I imagine you have done this deliberately, but since you haven't said that anywhere, I am pointing it out.
|
|
||
| public function __destruct() | ||
| { | ||
| $this->shutDown(); |
There was a problem hiding this comment.
This is a bit gross but it's the only way I could find to call the shutDown() method at the end of the test run.
test_bootstrap.php
Outdated
| @@ -1,3 +1,42 @@ | |||
| <?php | |||
|
|
|||
| exec(__DIR__ . "/tests"); | |||
There was a problem hiding this comment.
Makes sure all the right tmp dirs are present and have the correct permissions
| restore_exception_handler(); | ||
|
|
||
| // freeze the time | ||
| CakeTestCase::time(); |
There was a problem hiding this comment.
This was previously done with a call to static::time() inside CakeTestSuiteDispatcher right before it started the test suite.
|
|
||
| ini_set("memory_limit", "512M"); | ||
|
|
||
| define("TMP", "/home/vagrant/caketmp/"); |
There was a problem hiding this comment.
Cake doesn't have a way of configuring the path to the temp directory, so we have to set this constant before it can. We need to change the temp directory to be a folder which is not shared with the host OS, or the permissions-related tests will not pass.
No description provided.