Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reverted a change from this afternoon to fix includes.
Added a phpunits for first parts, rest follow soon hopefully. Fixed a few bugs I found while writing the tests.
- Loading branch information
Showing
73 changed files
with
841 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit backupGlobals="true" | ||
backupStaticAttributes="true" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
bootstrap="tests/bootstrap.php" | ||
> | ||
<testsuites> | ||
<testsuite name="phpBB Test Suite"> | ||
<directory suffix="_test.php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<blacklist> | ||
<directory>./tests/</directory> | ||
</blacklist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit backupGlobals="true" | ||
backupStaticAttributes="true" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
bootstrap="tests/bootstrap.php" | ||
> | ||
<testsuites> | ||
<testsuite name="phpBB Test Suite"> | ||
<directory suffix="_test.php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<groups> | ||
<exclude> | ||
<group>slow</group> | ||
</exclude> | ||
</groups> | ||
|
||
<filter> | ||
<blacklist> | ||
<directory>./tests/</directory> | ||
</blacklist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
/** | ||
* | ||
* @package testing | ||
* @copyright (c) 2008 phpBB Group | ||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License | ||
* | ||
*/ | ||
|
||
require_once 'test_framework/phpbb_test_case_helpers.php'; | ||
require_once 'test_framework/phpbb_test_case.php'; | ||
require_once 'includes/tests/test_base.php'; | ||
require_once 'test_framework/mpv_mock.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* | ||
* @package testing | ||
* @copyright (c) 2008 phpBB Group | ||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License | ||
* | ||
*/ | ||
|
||
require_once dirname(__FILE__) . '/../../includes/tests/tests_code.php'; | ||
|
||
class phpbb_binary_test extends phpbb_test_case | ||
{ | ||
private $test; | ||
public static function provider() | ||
{ | ||
// array(Input -> redirect(), expected triggered error (else false), expected returned result url (else false)) | ||
return array( | ||
array('testcode/noExtension', false, true), | ||
array('testcode/ignoreFile.php', false, false), | ||
array('testcode/noBinary', 'FILE_NON_BINARY', false), | ||
); | ||
} | ||
|
||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->test = new mpv_tests_code(new mpv); | ||
} | ||
|
||
/** | ||
* @dataProvider provider | ||
*/ | ||
public function test_binary($test, $expected_error, $expected_result) | ||
{ | ||
global $user; | ||
|
||
if ($expected_error !== false) | ||
{ | ||
$this->setExpectedTriggerError(E_USER_ERROR, $expected_error); | ||
} | ||
|
||
$result = $this->test->unittest('check_binary', array(('tests/code/' . $test))); | ||
|
||
$this->assertEquals($expected_result, $result); | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
/** | ||
* | ||
* @package testing | ||
* @copyright (c) 2008 phpBB Group | ||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License | ||
* | ||
*/ | ||
|
||
require_once dirname(__FILE__) . '/../../includes/tests/tests_code.php'; | ||
|
||
class phpbb_mysql_test extends phpbb_test_case | ||
{ | ||
private $test; | ||
public static function provider() | ||
{ | ||
// array(Input -> redirect(), expected triggered error (else false), expected returned result url (else false)) | ||
return array( | ||
array('testcode/dbal/mysql', 'USAGE_MYSQL', false), | ||
array('testcode/dbal/mysqli', 'USAGE_MYSQLI', false), | ||
array('testcode/dbal/oci', 'USAGE_OCI', false), | ||
array('testcode/dbal/sqlite', 'USAGE_SQLITE', false), | ||
array('testcode/dbal/pg', 'USAGE_PG', false), | ||
array('testcode/dbal/mssql', 'USAGE_MSSQL', false), | ||
array('testcode/dbal/odbc', 'USAGE_ODBC', false), | ||
array('testcode/dbal/sqlsrv', 'USAGE_SQLSRV', false), | ||
array('testcode/dbal/ibase', 'USAGE_IBASE', false), | ||
array('testcode/dbal/db2', 'USAGE_DB2', false), | ||
array('testcode/short2', false, true), | ||
); | ||
} | ||
|
||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->test = new mpv_tests_code(new mpv); | ||
} | ||
|
||
/** | ||
* @dataProvider provider | ||
*/ | ||
public function test_mysql($test, $expected_error, $expected_result) | ||
{ | ||
global $user; | ||
$this->test->setFilename('tests/code/' . $test); | ||
|
||
if ($expected_error !== false) | ||
{ | ||
$this->setExpectedTriggerError(E_USER_ERROR, $expected_error); | ||
} | ||
|
||
$result = $this->test->unittest('test_dbal', array()); | ||
|
||
$this->assertEquals($expected_result, $result); | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* | ||
* @package testing | ||
* @copyright (c) 2008 phpBB Group | ||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License | ||
* | ||
*/ | ||
|
||
require_once dirname(__FILE__) . '/../../includes/tests/tests_code.php'; | ||
|
||
class phpbb_empty_test extends phpbb_test_case | ||
{ | ||
private $test; | ||
public static function provider() | ||
{ | ||
// array(Input -> redirect(), expected triggered error (else false), expected returned result url (else false)) | ||
return array( | ||
array('testcode/emptyFile', 'FILE_EMPTY', false), | ||
array('testcode/noExtension', false, true), | ||
); | ||
} | ||
|
||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->test = new mpv_tests_code(new mpv); | ||
} | ||
|
||
/** | ||
* @dataProvider provider | ||
*/ | ||
public function test_empty($test, $expected_error, $expected_result) | ||
{ | ||
global $user; | ||
$this->test->setFilename('tests/code/' . $test); | ||
|
||
if ($expected_error !== false) | ||
{ | ||
$this->setExpectedTriggerError(E_USER_ERROR, $expected_error); | ||
} | ||
|
||
$result = $this->test->unittest('test_empty', array()); | ||
|
||
$this->assertEquals($expected_result, $result); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* | ||
* @package testing | ||
* @copyright (c) 2008 phpBB Group | ||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License | ||
* | ||
*/ | ||
|
||
require_once dirname(__FILE__) . '/../../includes/tests/tests_code.php'; | ||
|
||
class phpbb_function_test extends phpbb_test_case | ||
{ | ||
private $test; | ||
public static function provider() | ||
{ | ||
// array(Input -> redirect(), expected triggered error (else false), expected returned result url (else false)) | ||
return array( | ||
array('testcode/dbal/mysql', false, true), | ||
array('testcode/functions/eval', 'USAGE_EVAL', false), | ||
array('testcode/functions/exec', 'USAGE_EXEC', false), | ||
array('testcode/functions/system', 'USAGE_SYSTEM', false), | ||
array('testcode/functions/passthru', 'USAGE_PASSTHRU', false), | ||
array('testcode/functions/getenv', 'USAGE_GETENV', false), | ||
array('testcode/functions/die', 'USAGE_DIE', false), | ||
array('testcode/functions/sha1', 'USAGE_SHA1', false), | ||
array('testcode/functions/addslashes', 'USAGE_ADDSLASHES', false), | ||
array('testcode/functions/stripslashes', 'USAGE_STRIPSLASHES', false), | ||
|
||
array('testcode/functions/backticks', 'USAGE_`', false), | ||
|
||
array('testcode/functions/include_once', 'USAGE_INCLUDEONCE', false), | ||
array('testcode/functions/include_once2', 'USAGE_INCLUDEONCE', false), | ||
array('testcode/functions/require_once', 'USAGE_REQUIREONCE', false), | ||
array('testcode/functions/require_once2', 'USAGE_REQUIREONCE', false), | ||
array('testcode/functions/md5', 'USAGE_MD5', false), | ||
array('testcode/functions/md52', false, true), | ||
array('testcode/short2', false, true), | ||
); | ||
} | ||
|
||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->test = new mpv_tests_code(new mpv); | ||
} | ||
|
||
/** | ||
* @dataProvider provider | ||
*/ | ||
public function test_function($test, $expected_error, $expected_result) | ||
{ | ||
global $user; | ||
$this->test->setFilename('tests/code/' . $test); | ||
|
||
if ($expected_error !== false) | ||
{ | ||
$this->setExpectedTriggerError(E_USER_ERROR, $expected_error); | ||
} | ||
|
||
$result = $this->test->unittest('test_code', array()); | ||
|
||
if ($expected_error === false) | ||
$this->assertEquals($expected_result, $result); | ||
} | ||
} | ||
|
Oops, something went wrong.