-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…3634867] * phpcs.xml; phpunit.xml.dist; Initial unit tests.
- Loading branch information
Showing
13 changed files
with
330 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="mediaplayer-open-ac-uk"> | ||
<description>OU Media Player coding standard - PSR2, almost!</description> | ||
|
||
<!-- | ||
Stay as close to PSR-2 as possible, but account for CodeIgniter conventions. | ||
http://edorian.github.io/php-coding-standard-generator/#phpcs | ||
--> | ||
|
||
<exclude-pattern>\.git</exclude-pattern> | ||
<exclude-pattern>/application/assets/</exclude-pattern> | ||
<exclude-pattern>/application/cli/</exclude-pattern> | ||
<exclude-pattern>/application/config/</exclude-pattern> | ||
<exclude-pattern>/application/engines/</exclude-pattern> | ||
<exclude-pattern>/application/errors/</exclude-pattern> | ||
<exclude-pattern>/application/language/</exclude-pattern> | ||
<exclude-pattern>/system/</exclude-pattern> | ||
<exclude-pattern>/vendor/</exclude-pattern> | ||
<exclude-pattern>*/*.html</exclude-pattern> | ||
<exclude-pattern>*/*BAK*</exclude-pattern> | ||
|
||
<!-- Exclude third-party libraries. --> | ||
<exclude-pattern>src/FirePHPCore</exclude-pattern> | ||
<exclude-pattern>src/class.pdf2text.php</exclude-pattern> | ||
<exclude-pattern>src/POParser.php</exclude-pattern> | ||
|
||
<!-- Why does `phpcbf` fail on http.php ?? --> | ||
<exclude-pattern>libraries/ht--tp.php</exclude-pattern> | ||
|
||
<!-- Temporarily exclude all views and provider-libraries. --> | ||
<exclude-pattern>*/views/*</exclude-pattern> | ||
<exclude-pattern>src/providers/</exclude-pattern> | ||
|
||
|
||
<rule ref="PSR2"> | ||
<exclude name="PSR2.Methods.MethodDeclaration"/> | ||
<!--<exclude name="PSR2.Classes.PropertyDeclaration"/>--> | ||
</rule> | ||
|
||
<rule ref="PSR1"> | ||
<exclude name="PSR1.Methods.CamelCapsMethodName"/> | ||
|
||
<!-- | ||
For the moment, don't require namespaces. | ||
--> | ||
<!--<exclude name="PSR1.Classes.ClassDeclaration"/>--> | ||
|
||
<!--<exclude name="PSR1.Files.SideEffects"/>--> | ||
</rule> | ||
|
||
<rule ref="Squiz.Classes"> | ||
<exclude name="Squiz.Classes.ValidClassName"/> | ||
</rule> | ||
|
||
<!-- "%s name doesn't match filename; expected"--> | ||
<rule ref="Squiz.Classes"> | ||
<exclude-pattern>/application/controllers/</exclude-pattern> | ||
|
||
<exclude name="Squiz.Classes.ValidClassName"/> | ||
<!--<exclude name="Squiz.Classes.ClassFileName"/>--> | ||
</rule> | ||
|
||
<!-- | ||
Accept class names like "MY_Controller". | ||
--> | ||
<rule ref="PEAR.NamingConventions.ValidClassName"/> | ||
|
||
|
||
<!--<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>--> | ||
|
||
<!--<rule ref="Squiz.Classes.LowercaseClassKeywords"/>--> | ||
|
||
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/> | ||
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/> | ||
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/> | ||
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/> | ||
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/> | ||
|
||
<rule ref="Generic.Commenting.Todo"/> | ||
|
||
<rule ref="Generic.Files.LineEndings"/> | ||
|
||
<rule ref="Generic.PHP.DeprecatedFunctions"/> | ||
<rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops"/> | ||
<rule ref="Squiz.PHP.Eval"/> | ||
<rule ref="Generic.PHP.ForbiddenFunctions"/> | ||
<rule ref="Squiz.PHP.NonExecutableCode"/> | ||
<!--<rule ref="Generic.PHP.NoSilencedErrors"/>--> | ||
|
||
<rule ref="Squiz.Scope.MemberVarScope"/> | ||
<rule ref="Squiz.Scope.StaticThisUsage"/> | ||
|
||
<rule ref="Squiz.WhiteSpace.CastSpacing"/> | ||
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/> | ||
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/> | ||
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/> | ||
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/> | ||
|
||
<!-- All rules in ./Sniffs are included automatically --> | ||
</ruleset> |
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"?> | ||
<phpunit | ||
bootstrap="./vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
verbose="true" | ||
stopOnFailure="false" | ||
processIsolation="false" | ||
backupGlobals="false" | ||
syntaxCheck="true" | ||
> | ||
<testsuite name="IET_OU\Open_Media_Player core tests"> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
<filter> | ||
<whitelist addUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">./src</directory> | ||
</whitelist> | ||
</filter> | ||
<logging> | ||
<log type="coverage-clover" target="./coverage.clover"/> | ||
</logging> | ||
</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,79 @@ | ||
<?php namespace IET_OU\Open_Media_Player; | ||
|
||
/** | ||
* THE single base class, for extensible components of Open Media Player. | ||
* | ||
* @copyright Copyright 2011-2015 The Open University. | ||
* @author N.D.Freear, 18 June 2015. | ||
* @link http://www.codeigniter.com/userguide2/ | ||
*/ | ||
|
||
abstract class Base | ||
{ | ||
public static $throw_no_framework = true; | ||
|
||
protected $CI; | ||
|
||
public function __construct() | ||
{ | ||
// Is CodeIgniter present? | ||
if (defined('CI_VERSION') && function_exists('get_instance')) { | ||
$ci =& \get_instance(); | ||
|
||
if ($ci instanceof IET_OU\Open_Media_Player\MY_Controller) { | ||
$this->CI = $ci; | ||
} | ||
} | ||
if (!$this->CI) { | ||
$this->throw_no_framework_found_warning(__METHOD__, func_get_args()); | ||
} | ||
} | ||
|
||
protected function get_param($key, $default = null, $filter = FILTER_SANITIZE_STRING, $options = null) | ||
{ | ||
$value = filter_input(INPUT_GET, $key, $filter, $options); | ||
return $value ? $value : $default; | ||
// Alt: $this->CI->input->get(); | ||
} | ||
|
||
/** Get a configuration item, set a default if it doesn't exist. | ||
*/ | ||
protected function config_item($item, $default = null, $index = '') | ||
{ | ||
if ($this->CI) { | ||
$value = $this->CI->config->item($item, $index); | ||
return $value ? $value : $default; | ||
} else { | ||
$this->throw_no_framework_found_warning(__METHOD__, func_get_args()); | ||
} | ||
} | ||
|
||
protected function _log($level = 'error', $message = 'unknown', $php_error = false) | ||
{ | ||
if ($this->CI) { | ||
return $this->CI->_log($level, $message, $php_error); | ||
} else { | ||
$this->throw_no_framework_found_warning(__METHOD__, func_get_args()); | ||
} | ||
} | ||
|
||
/** Display an error message and exit? | ||
*/ | ||
protected function _error($message, $code = 500, $from = null, $obj = null) | ||
{ | ||
if ($this->CI) { | ||
return $this->CI->_error($mesage, $code, $from, $obj); | ||
} else { | ||
$this->throw_no_framework_found_warning(__METHOD__, func_get_args()); | ||
} | ||
} | ||
|
||
protected function throw_no_framework_found_warning($function, $args = null) | ||
{ | ||
if (static::$throw_no_framework) { | ||
throw new \Exception('No CodeIgniter framework found: '. $function); | ||
} else { | ||
echo "Warning: no CodeIgniter framework found: $function\n"; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.