Permalink
Browse files

Unit tests & formatter stuff

  • Loading branch information...
r04r committed Feb 11, 2016
1 parent 1c5fa2a commit b2b9a6fd07508ff332c75916b6346623609ec4e1
View
@@ -5,4 +5,6 @@
/dump/
db.log
/composer.phar
/vendor
/phpunit.phar
/vendor
/.php_cs.cache
View
13 .php_cs
@@ -0,0 +1,13 @@
<?php
$finder = Symfony\CS\Finder\DefaultFinder::create()
->ignoreDotFiles(true)
->ignoreVCS(true)
->exclude('vendor')
->in(__DIR__)
;
return Symfony\CS\Config\Config::create()
->setUsingCache(true)
->finder($finder)
;
@@ -35,7 +35,7 @@ function token_exists($rand_token)
global $link;
$result = $link->db_exec('SELECT 1 FROM android_tokens WHERE rand_token = %1 LIMIT 1', $rand_token);
return ($link->num_rows() > 0);
return $link->num_rows() > 0;
}
$link = new db($db_info['server'], $db_info['username'], $db_info['password'], $db_info['database']);
@@ -304,7 +304,7 @@ protected static function _log(array $args)
/**
* converts an object to a better format for logging.
*
* @param Object
* @param object
*
* @return array
*/
@@ -10,4 +10,4 @@
$parser->parse($text);
print $parser->getAsHtml();
echo $parser->getAsHtml();
@@ -8,4 +8,4 @@
$text = 'The bbcode in here [b]is never closed!';
$parser->parse($text);
print $parser->getAsBBCode();
echo $parser->getAsBBCode();
@@ -9,4 +9,4 @@
$text .= '[color=#333333]text[/color]![/u][/b]';
$parser->parse($text);
print $parser->getAsText();
echo $parser->getAsText();
@@ -22,6 +22,6 @@ public function validate($input)
{
$valid = filter_var($input, FILTER_VALIDATE_URL);
return !!$valid;
return (bool) $valid;
}
}
View
@@ -48,15 +48,20 @@
function sanitize($type, $val)
{
switch($type) {
switch ($type) {
case 'uid':
case 'profile':
if(!allowed('open_profile')) return null;
if (!allowed('open_profile')) {
return;
}
break;
case 'ip':
if(!allowed('open_ip')) return null;
if (!allowed('open_ip')) {
return;
}
break;
}
return $val;
}
View
@@ -20,7 +20,7 @@ function ipCIDRCheck($IP, $CIDR)
$ip_ip = ip2long($IP);
$ip_ip_net = $ip_ip & $ip_mask;
return ($ip_ip_net == $ip_net);
return $ip_ip_net == $ip_net;
}
if (isset($_SERVER['HTTP_CF_CONNECTING_IP']) && isset($_SERVER['HTTP_CF_IPCOUNTRY'])) {
@@ -240,10 +240,14 @@ function performBanCheck($table, $column, $value, $template)
$private_stealth_banned = $stealth_banned;
$stealth_banned = false;
if($_COOKIE['UID']) performBanCheck('uid_bans', 'uid', $_COOKIE['UID'], 'uid_ban');
if ($_COOKIE['UID']) {
performBanCheck('uid_bans', 'uid', $_COOKIE['UID'], 'uid_ban');
}
performBanCheck('uid_bans', 'uid', $_SESSION['UID'], 'uid_ban');
performBanCheck('ip_bans', 'ip_address', $_SERVER['REMOTE_ADDR'], 'ip_ban');
if($private_stealth_banned) $stealth_banned = true;
if ($private_stealth_banned) {
$stealth_banned = true;
}
if ($_SESSION['last_posts_check'] < time() - 120 || !ENABLE_CACHING) {
// Panic mode check, this can prolly be done more efficient.
View
@@ -37,9 +37,9 @@
<meta name="keywords" content="minichan, bbs, board, anonymous, free, debate, discuss, argue, drama, loldrama, youarenowbrowsingmanually" />
<title><?php echo strip_tags($page_title).''.SITE_TITLE ?></title>
<link rel="icon" type="image/gif" href="<?php echo STATIC_DOMAIN; ?>favicon.gif" />
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo(STATIC_DOMAIN.'style/layout.css') ?>?20" />
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo(($custom_stylesheet) ? htmlspecialchars($custom_stylesheet) : (STATIC_DOMAIN.'style/'.$stylesheet.'.css?3')) ?>" />
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo(STATIC_DOMAIN.'javascript/highlight-styles/vs.css') ?>" />
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo STATIC_DOMAIN.'style/layout.css' ?>?20" />
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo ($custom_stylesheet) ? htmlspecialchars($custom_stylesheet) : (STATIC_DOMAIN.'style/'.$stylesheet.'.css?3') ?>" />
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo STATIC_DOMAIN.'javascript/highlight-styles/vs.css' ?>" />
<?php if (MOBILE_MODE) {
?>
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo STATIC_DOMAIN.'style/mobile.css' ?>" />
@@ -121,7 +121,7 @@
}?>]);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/<?php echo(($administrator && false) ? 'u/ga_debug.js' : 'ga.js')?>';
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/<?php echo ($administrator && false) ? 'u/ga_debug.js' : 'ga.js'?>';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
@@ -300,7 +300,7 @@
if ($administrator) {
function humanize_bytes($size)
{
$unit = array('B','KB','MB','GB','TB','PB');
$unit = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2).$unit[$i];
}
View
@@ -22,7 +22,7 @@
$width = 199;
$background_color = 'FFFFFF'; // background-color of the chart...
$text_color = '000000'; // text-color.
$colors = array('003366', 'CCD6E0', '7F99B2','F7EFC6', 'C6BE8C', 'CC6600','990000','520000','BFBFC1','808080'); // colors of the slices.
$colors = array('003366', 'CCD6E0', '7F99B2', 'F7EFC6', 'C6BE8C', 'CC6600', '990000', '520000', 'BFBFC1', '808080'); // colors of the slices.
$shadow_height = 16; // Height on shadown.
$shadow_dark = true; // true = darker shadow, false = lighter shadow...
@@ -22,7 +22,7 @@
$width = 199;
$background_color = 'FFFFFF'; // background-color of the chart...
$text_color = '000000'; // text-color.
$colors = array('003366', 'CCD6E0', '7F99B2','F7EFC6', 'C6BE8C', 'CC6600','990000','520000','BFBFC1','808080'); // colors of the slices.
$colors = array('003366', 'CCD6E0', '7F99B2', 'F7EFC6', 'C6BE8C', 'CC6600', '990000', '520000', 'BFBFC1', '808080'); // colors of the slices.
$shadow_height = 16; // Height on shadown.
$shadow_dark = true; // true = darker shadow, false = lighter shadow...
View
@@ -22,7 +22,7 @@
$width = 199;
$background_color = 'FFFFFF'; // background-color of the chart...
$text_color = '000000'; // text-color.
$colors = array('003366', 'CCD6E0', '7F99B2','F7EFC6', 'C6BE8C', 'CC6600','990000','520000','BFBFC1','808080'); // colors of the slices.
$colors = array('003366', 'CCD6E0', '7F99B2', 'F7EFC6', 'C6BE8C', 'CC6600', '990000', '520000', 'BFBFC1', '808080'); // colors of the slices.
$shadow_height = 16; // Height on shadown.
$shadow_dark = true; // true = darker shadow, false = lighter shadow...
@@ -22,7 +22,7 @@
$width = 199;
$background_color = 'FFFFFF'; // background-color of the chart...
$text_color = '000000'; // text-color.
$colors = array('003366', 'CCD6E0', '7F99B2','F7EFC6', 'C6BE8C', 'CC6600','990000','520000','BFBFC1','808080'); // colors of the slices.
$colors = array('003366', 'CCD6E0', '7F99B2', 'F7EFC6', 'C6BE8C', 'CC6600', '990000', '520000', 'BFBFC1', '808080'); // colors of the slices.
$shadow_height = 16; // Height on shadown.
$shadow_dark = true; // true = darker shadow, false = lighter shadow...
View
@@ -22,7 +22,7 @@
$width = 199;
$background_color = 'FFFFFF'; // background-color of the chart...
$text_color = '000000'; // text-color.
$colors = array('003366', 'CCD6E0', '7F99B2','F7EFC6', 'C6BE8C', 'CC6600','990000','520000','BFBFC1','808080'); // colors of the slices.
$colors = array('003366', 'CCD6E0', '7F99B2', 'F7EFC6', 'C6BE8C', 'CC6600', '990000', '520000', 'BFBFC1', '808080'); // colors of the slices.
$shadow_height = 16; // Height on shadown.
$shadow_dark = true; // true = darker shadow, false = lighter shadow...
@@ -22,7 +22,7 @@
$width = 199;
$background_color = 'FFFFFF'; // background-color of the chart...
$text_color = '000000'; // text-color.
$colors = array('003366', 'CCD6E0', '7F99B2','F7EFC6', 'C6BE8C', 'CC6600','990000','520000','BFBFC1','808080'); // colors of the slices.
$colors = array('003366', 'CCD6E0', '7F99B2', 'F7EFC6', 'C6BE8C', 'CC6600', '990000', '520000', 'BFBFC1', '808080'); // colors of the slices.
$shadow_height = 16; // Height on shadown.
$shadow_dark = true; // true = darker shadow, false = lighter shadow...
View
@@ -102,7 +102,6 @@ class paypal_class
public $fields = array(); // array holds the fields to submit to paypal
public function paypal_class()
{
View
@@ -0,0 +1,6 @@
#!/bin/bash
set -x
git status
php-cs-fixer fix . --verbose
phpunit tests
git status
View
@@ -37,7 +37,7 @@ function uid_exists($uid)
global $link;
$result = $link->db_exec('SELECT 1 FROM shorturls WHERE id = %1 LIMIT 1', $uid);
return ($link->num_rows() > 0);
return $link->num_rows() > 0;
}
do {
View
@@ -304,7 +304,7 @@ protected static function _log(array $args)
/**
* converts an object to a better format for logging.
*
* @param Object
* @param object
*
* @return array
*/
View
@@ -0,0 +1,3 @@
Options -Indexes -ExecCGI
Order Allow,Deny
Deny from all
View
@@ -0,0 +1,51 @@
<?php
class SampleTest extends PHPUnit_Framework_TestCase
{
protected function setUp()
{
require_once 'vendor/autoload.php';
require_once 'includes/config.php';
require_once 'includes/database.class.php';
require_once 'includes/functions.php';
require_once 'includes/async_functions.php';
require_once 'includes/unicode.php';
}
public function testMatchIgnoredName()
{
$this->assertTrue(matchIgnoredName(array(
'ayy !lmao',
), 'ayy', '!lmao'));
$this->assertTrue(matchIgnoredName(array(
'ayy !lmao',
), 'ayy', ' !lmao'));
$this->assertFalse(matchIgnoredName(array(
'ayy !lmao',
), 'ayy', '!lmaoo'));
$this->assertFalse(matchIgnoredName(array(
'ayy !lmao',
), 'ayy', '!lma'));
$this->assertTrue(matchIgnoredName(array(
'something !else',
'ayy !lmao',
), 'ayy', '!lmao'));
$this->assertTrue(matchIgnoredName(array(
'ayy !lmao',
'something !else',
), 'ayy', '!lmao'));
$this->assertTrue(matchIgnoredName(array(
'!lmao',
), 'ayy', '!lmao'));
$this->assertTrue(matchIgnoredName(array(
'ayy',
), 'ayy', '!lmao'));
}
}

0 comments on commit b2b9a6f

Please sign in to comment.