Skip to content

Commit

Permalink
Merge pull request #1740 from jim-parry/admin/testing
Browse files Browse the repository at this point in the history
Refactor test support for app starter
  • Loading branch information
jim-parry authored Feb 18, 2019
2 parents 5939bea + ff40dbe commit 5fd98b4
Show file tree
Hide file tree
Showing 11 changed files with 150 additions and 15 deletions.
2 changes: 1 addition & 1 deletion admin/release-appstarter
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ git checkout $branch
echo -e "${BOLD}Build the framework distributable${NORMAL}"

echo -e "${BOLD}Copy the main files/folders...${NORMAL}"
releasable='app public writable README.md contributing.md env license.txt spark'
releasable='app public writable README.md contributing.md env license.txt spark tests/_support'
for fff in $releasable ; do
if [ -d "$fff" ] ; then
rm -rf $fff
Expand Down
2 changes: 1 addition & 1 deletion admin/release-framework
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ git checkout $branch
echo -e "${BOLD}Build the framework distributable${NORMAL}"

echo -e "${BOLD}Copy the main files/folders...${NORMAL}"
releasable='app docs public system writable contributing.md env license.txt spark'
releasable='app docs public system writable contributing.md env license.txt spark tests/_support'
for fff in $releasable ; do
if [ -d "$fff" ] ; then
rm -rf $fff
Expand Down
28 changes: 28 additions & 0 deletions admin/starter/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/_support/_bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false">
<testsuites>
<testsuite name="app">
<directory>./tests</directory>
<exclude>./tests/system</exclude>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./system</directory>
<exclude>
<directory>./system</directory>
</exclude>
</whitelist>
</filter>

</phpunit>
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
<?php namespace Tests\Support\Helpers;
<?php namespace CodeIgniter\Test;

/**
* CodeIgniter
*
* An open source application development framework for PHP
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2014-2019 British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @package CodeIgniter
* @author CodeIgniter Dev Team
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
* @since Version 3.0.0
* @filesource
*/

use Tests\Support\DOM\DOMParser;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,40 @@
<?php namespace Tests\Support\Helpers;
<?php namespace CodeIgniter\Test;

/**
* CodeIgniter
*
* An open source application development framework for PHP
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2014-2019 British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @package CodeIgniter
* @author CodeIgniter Dev Team
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
* @since Version 3.0.0
* @filesource
*/

use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\Response;
Expand Down Expand Up @@ -73,7 +109,7 @@ public function controller(string $name)
* @param string $method
* @param array $params
*
* @return \Tests\Support\Helpers\ControllerResponse
* @return \CodeIgniter\TestControllerResponse
*/
public function execute(string $method, ...$params)
{
Expand Down
40 changes: 38 additions & 2 deletions tests/_support/DOM/DOMParser.php → system/Test/DOMParser.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,40 @@
<?php namespace Tests\Support\DOM;
<?php namespace CodeIgniter\Test;

/**
* CodeIgniter
*
* An open source application development framework for PHP
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2014-2019 British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @package CodeIgniter
* @author CodeIgniter Dev Team
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
* @since Version 3.0.0
* @filesource
*/

class DOMParser
{
Expand Down Expand Up @@ -59,7 +95,7 @@ public function withString(string $content)
*
* @param string $path
*
* @return \Tests\Support\DOM\DOMParser
* @return \CodeIgniter\Test\DOMParser
*/
public function withFile(string $path)
{
Expand Down
3 changes: 1 addition & 2 deletions system/Test/FeatureResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\Response;
use PHPUnit\Framework\TestCase;
use Tests\Support\DOM\DOMParser;

class FeatureResponse extends TestCase
{
Expand All @@ -13,7 +12,7 @@ class FeatureResponse extends TestCase
public $response;

/**
* @var \Tests\Support\DOM\DOMParser
* @var \CodeIgniter\Test\DOMParser
*/
protected $domParser;

Expand Down
3 changes: 3 additions & 0 deletions tests/system/Database/Live/SQLite/AlterTableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
use CodeIgniter\Database\SQLite3\Table;
use Config\Database;

/**
* @group DatabaseLive
*/
class AlterTableTest extends CIDatabaseTestCase
{
protected $refresh = true;
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Helpers/FilesystemHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public function testRealPathInvalid()

public function testRealPathResolved()
{
$this->assertEquals(SUPPORTPATH . 'Helpers/', set_realpath(SUPPORTPATH . 'Files/../Helpers', true));
$this->assertEquals(SUPPORTPATH . 'Models/', set_realpath(SUPPORTPATH . 'Files/../Models', true));
}

}
2 changes: 0 additions & 2 deletions tests/system/Test/DOMParserTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php namespace CodeIgniter\Test;

use Tests\Support\DOM\DOMParser;

class DOMParserTest extends CIUnitTestCase
{
protected function setUp()
Expand Down
4 changes: 2 additions & 2 deletions user_guide_src/source/testing/controllers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ within your tests::

<?php namespace CodeIgniter;

use Tests\Support\Helpers\ControllerTester;
use CodeIgniter\Test\ControllerTester;

class TestControllerA extends \CIDatabaseTestCase
{
Expand All @@ -32,7 +32,7 @@ to run as the parameter::

<?php namespace CodeIgniter;

use Tests\Support\Helpers\ControllerTester;
use CodeIgniter\Test\ControllerTester;

class TestControllerA extends \CIDatabaseTestCase
{
Expand Down

0 comments on commit 5fd98b4

Please sign in to comment.