Browse Source

PHP 7 fixes and jenkins/sonarqube configs

master
Timothy Warren 4 years ago
parent
commit
7ef0482dec
22 changed files with 437 additions and 149 deletions
  1. +3
    -0
      .travis.yml
  2. +1
    -1
      application/config/config.php
  3. +2
    -0
      application/config/sites.php
  4. +3
    -8
      application/controllers/calendar.php
  5. +1
    -0
      application/controllers/task.php
  6. +23
    -23
      application/libraries/Page.php
  7. +0
    -10
      application/logs/index.html
  8. +0
    -10
      application/models/friend_model.php
  9. +11
    -26
      application/models/task_model.php
  10. +1
    -1
      application/views/friend/manage.php
  11. +10
    -10
      application/views/task/add.php
  12. +18
    -16
      application/views/task/edit.php
  13. +268
    -0
      build.xml
  14. +48
    -0
      build/phpunit.xml
  15. +6
    -0
      sonar-project.properties
  16. +4
    -4
      system/core/Common.php
  17. +1
    -1
      system/core/Config.php
  18. +1
    -1
      system/core/Lang.php
  19. +1
    -1
      system/libraries/Log.php
  20. +6
    -8
      tests/env/autoloader.php
  21. +10
    -10
      tests/phpunit.xml
  22. +19
    -19
      web/css/todo.css

+ 3
- 0
.travis.yml View File

@@ -1,9 +1,12 @@
language: php

sudo: false

php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm

install:

+ 1
- 1
application/config/config.php View File

@@ -1,4 +1,4 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
<?php //if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
|--------------------------------------------------------------------------

+ 2
- 0
application/config/sites.php View File

@@ -1,5 +1,7 @@
<?php
$config = [];
include "config.php";
$config['base_url'] = (isset($config['base_url'])) ? $config['base_url'] : 'https://todo.timshomepage.net/';
/*
|--------------------------------------------------------------------------
| Content Domain

+ 3
- 8
application/controllers/calendar.php View File

@@ -13,7 +13,7 @@ class Calendar extends MY_Controller {
parent::__construct();
$this->load->library('calendar');
$this->load->model('task_model');
}

/**
@@ -40,17 +40,12 @@ class Calendar extends MY_Controller {
}

$_months = array(
01 => 'January', 02 => 'February',
03 => 'March', 04 => 'April',
05 => 'May', 06 => 'June',
07 => 'July', 08 => 'August',
09 => 'September', 10 => 'October',
11 => 'November', 12 => 'December',
1 => 'January', 2 => 'February',
3 => 'March', 4 => 'April',
5 => 'May', 6 => 'June',
7 => 'July', 8 => 'August',
9 => 'September',
9 => 'September', 10 => 'October',
11 => 'November', 12 => 'December'
);

$year = (isset($year)) ? $year : date('Y');

+ 1
- 0
application/controllers/task.php View File

@@ -179,6 +179,7 @@ class Task extends MY_Controller {
{
$task_id = (int) $task_id;
$data = $this->task_model->get_task_by_id($task_id);

$data['cat_list'] = $this->task_model->get_category_select($task_id);
$data['pri_list'] = $this->task_model->get_priority_select($task_id);
$data['stat_list'] = $this->task_model->get_status_select($task_id);

+ 23
- 23
application/libraries/Page.php View File

@@ -7,8 +7,8 @@
* build_header(), build_footer(), and _headers() methods.
*/
class Page {
private static $meta, $head_js, $foot_js, $css, $title,
private $meta, $head_js, $foot_js, $css, $title,
$head_tags, $body_id;

/**
@@ -32,7 +32,7 @@ class Page {
$this->body_id = "";
$this->CI =& get_instance();
}
// --------------------------------------------------------------------------

/**
@@ -48,7 +48,7 @@ class Page {
{
$this->CI->output->set_header("Cache-Control: must-revalidate, public");
$this->CI->output->set_header("Vary: Accept");
//Predefine charset and mime
$charset = "UTF-8";
$mime = "text/html";
@@ -59,17 +59,17 @@ class Page {
$this->CI->output->set_header("Content-Type: $mime;charset=$charset");
$this->CI->output->set_header("X-UA-Compatible: chrome=1");
$this->CI->output->set_output($doctype_string);
return $this;
}
// --------------------------------------------------------------------------

/**
* Set Meta
*
* Sets meta tags, with codeigniter native meta tag helper
*
*
* @param array $meta
* @return Page
*/
@@ -78,7 +78,7 @@ class Page {
$this->meta .= T1.meta($meta).NL;
return $this;
}
// --------------------------------------------------------------------------

/**
@@ -94,7 +94,7 @@ class Page {
$this->head_js .= $this->script_tag($file, FALSE);
return $this;
}
// --------------------------------------------------------------------------

/**
@@ -128,7 +128,7 @@ class Page {
$this->foot_js .= $this->script_tag($file, FALSE);
return $this;
}
// --------------------------------------------------------------------------

/**
@@ -140,12 +140,12 @@ class Page {
{
$title = ($title == "") ?
$this->CI->config->item('default_title') : $title;
$this->title = $title;
return $this;
}
// --------------------------------------------------------------------------

/**
@@ -160,7 +160,7 @@ class Page {
}

// --------------------------------------------------------------------------
/**
* Sets custom page header
* @return $this
@@ -199,10 +199,10 @@ class Page {

//Output Header
$this->CI->load->view('header', $data);
return $this;
}
// --------------------------------------------------------------------------

/**
@@ -233,9 +233,9 @@ class Page {

$this->CI->load->view('footer', $data);
}
// --------------------------------------------------------------------------
/**
* Script Tag
*
@@ -261,21 +261,21 @@ class Page {
}

// --------------------------------------------------------------------------
/**
* Num Queries
*
*
* Returns number of queries run on a page
*
*
* @return int
*/
public function num_queries()
{
return (isset($this->CI->db)) ? count($this->CI->db->queries) : 0;
}
// --------------------------------------------------------------------------
/**
* Set Message
*

+ 0
- 10
application/logs/index.html View File

@@ -1,10 +0,0 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>

<p>Directory access is forbidden.</p>

</body>
</html>

+ 0
- 10
application/models/friend_model.php View File

@@ -5,16 +5,6 @@
*/
class Friend_model extends CI_Model {

/**
* Constructor
*/
public function __construct()
{
parent::__construct();
}

// --------------------------------------------------------------------------

/**
* Get Friends
*

+ 11
- 26
application/models/task_model.php View File

@@ -186,14 +186,9 @@ class Task_model extends CI_Model {
->where('user_id', $uid)
->delete('item_comments');

if($this->db->affected_rows() > 0)
{
return $this->db->affected_rows();
}
else
{
return -1;
}
return ($this->db->affected_rows() > 0)
? $this->db->affected_rows()
: -1;
}

// --------------------------------------------------------------------------
@@ -317,7 +312,7 @@ class Task_model extends CI_Model {
$result_array[$i] = $row;

// Overdue is set as false to cut down on visual noise.
// Since every task in the list is overdue, using the
// Since every task in the list is overdue, using the
// visual style is redundant
$result_array[$i]['overdue'] = FALSE;
$i++;
@@ -616,12 +611,12 @@ class Task_model extends CI_Model {
*/
public function update_task()
{
$title = $this->title;
$desc = str_replace('<br>', '<br />', $this->description);
$category = $this->category;
$priority = $this->priority;
$status = $this->status;
$due = $this->due;
$title = $this->input->post('title');;
$desc = str_replace('<br>', '<br />', $this->input->post('desc'));
$category = $this->input->post('category');
$priority = $this->input->post('priority');
$status = $this->input->post('status');
$due = $this->input->post('due');
$uid = $this->user_id;
$task_id = $this->task_id;

@@ -1161,17 +1156,7 @@ class Task_model extends CI_Model {


//Check if the user has permission
if($admin === TRUE)
{
$this->_remove_task($task_id);
return;
}
else if($user_admin === TRUE)
{
$this->_remove_task($task_id);
return;
}
else if($group_admin === TRUE)
if($admin === TRUE || $user_admin === TRUE || $group_admin === TRUE)
{
$this->_remove_task($task_id);
return;

+ 1
- 1
application/views/friend/manage.php View File

@@ -3,7 +3,7 @@
<?php $group_id = $this->uri->segment('3'); ?>
<section class="right">
<h1>Manage Group</h1>
<form action="<?= site_url("group/manage") .'/'. $group_id ?>" method="post">
<?= form_open("group/manage/" . (int)$group_id) ?>
<fieldset>
<legend>Group Members</legend>
<dl>

+ 10
- 10
application/views/task/add.php View File

@@ -35,16 +35,16 @@
<input type="text" name="due" id="due" value="<?= date('Y-m-d', $due) ?>" placeholder="YYYY-MM-DD" size="10" />
<label>Hour:
<select name="due_hour">
<option value="00"<?= (date('H', $due) == 00) ? ' selected="selected"' : "" ?>>Midnight</option>
<option value="01"<?= (date('H', $due) == 01) ? ' selected="selected"' : "" ?>>1 AM</option>
<option value="02"<?= (date('H', $due) == 02) ? ' selected="selected"' : "" ?>>2 AM</option>
<option value="03"<?= (date('H', $due) == 03) ? ' selected="selected"' : "" ?>>3 AM</option>
<option value="04"<?= (date('H', $due) == 04) ? ' selected="selected"' : "" ?>>4 AM</option>
<option value="05"<?= (date('H', $due) == 05) ? ' selected="selected"' : "" ?>>5 AM</option>
<option value="06"<?= (date('H', $due) == 06) ? ' selected="selected"' : "" ?>>6 AM</option>
<option value="07"<?= (date('H', $due) == 07) ? ' selected="selected"' : "" ?>>7 AM</option>
<option value="08"<?= (date('H', $due) == 08) ? ' selected="selected"' : "" ?>>8 AM</option>
<option value="09"<?= (date('H', $due) == 09) ? ' selected="selected"' : "" ?>>9 AM</option>
<option value="00"<?= (date('H', $due) == 0) ? ' selected="selected"' : "" ?>>Midnight</option>
<option value="01"<?= (date('H', $due) == 1) ? ' selected="selected"' : "" ?>>1 AM</option>
<option value="02"<?= (date('H', $due) == 2) ? ' selected="selected"' : "" ?>>2 AM</option>
<option value="03"<?= (date('H', $due) == 3) ? ' selected="selected"' : "" ?>>3 AM</option>
<option value="04"<?= (date('H', $due) == 4) ? ' selected="selected"' : "" ?>>4 AM</option>
<option value="05"<?= (date('H', $due) == 5) ? ' selected="selected"' : "" ?>>5 AM</option>
<option value="06"<?= (date('H', $due) == 6) ? ' selected="selected"' : "" ?>>6 AM</option>
<option value="07"<?= (date('H', $due) == 7) ? ' selected="selected"' : "" ?>>7 AM</option>
<option value="08"<?= (date('H', $due) == 8) ? ' selected="selected"' : "" ?>>8 AM</option>
<option value="09"<?= (date('H', $due) == 9) ? ' selected="selected"' : "" ?>>9 AM</option>
<option value="10"<?= (date('H', $due) == 10) ? ' selected="selected"' : "" ?>>10 AM</option>
<option value="11"<?= (date('H', $due) == 11) ? ' selected="selected"' : "" ?>>11 AM</option>
<option value="12"<?= (date('H', $due) == 12) ? ' selected="selected"' : "" ?>>12 Noon</option>

+ 18
- 16
application/views/task/edit.php View File

@@ -4,19 +4,19 @@
<?php if($user_perms == PERM_ADMIN_ACCESS): ?>
<p id="delTask"><a href="#" onclick="if(confirm('Are you sure you want to delete this task')){window.location='<?= site_url('task/delete').'/'.$this->security->xss_clean($this->uri->segment('3')) ?>'}">Delete Task</a></p>
<?php endif ?>
<?= form_open('task/edit' . '/' . $this->uri->segment(3)); ?>
<?= form_open('task/edit' . '/' . (int)$this->uri->segment(3)); ?>

<fieldset>
<legend>Task</legend>
<dl>
<dt><label for="title">Title</label></dt>
<dd>
<input type="text" name="title" id="title" value="<?= set_value('title') ?>" placeholder="Task Heading" />
<input type="text" name="title" id="title" value="<?= $title ?>" placeholder="Task Heading" />
</dd>

<dt><label for="desc">Description</label></dt>
<dd>
<textarea rows="10" cols="80" name="desc" id="desc" placeholder="Task details"><?= set_value('description') ?></textarea>
<textarea rows="10" cols="80" name="desc" id="desc" placeholder="Task details"><?= $description ?></textarea>
</dd>

<dt><label for="category">Category</label></dt>
@@ -32,7 +32,7 @@
<?= $pri_list ?>
</select>
</dd>
<dt><label for="status">Status</label></dt>
<dd>
<select name="status" id="status">
@@ -45,16 +45,16 @@
<input type="text" name="due" id="due" value="<?= ($due != 0) ? date('Y-m-d', $due) : 0 ?>" placeholder="YYYY-MM-DD" size="10" />
<label>Hour:
<select name="due_hour">
<option value="00"<?= (date('H', $due) == 00) ? ' selected="selected"' : "" ?>>Midnight</option>
<option value="01"<?= (date('H', $due) == 01) ? ' selected="selected"' : "" ?>>1 AM</option>
<option value="02"<?= (date('H', $due) == 02) ? ' selected="selected"' : "" ?>>2 AM</option>
<option value="03"<?= (date('H', $due) == 03) ? ' selected="selected"' : "" ?>>3 AM</option>
<option value="04"<?= (date('H', $due) == 04) ? ' selected="selected"' : "" ?>>4 AM</option>
<option value="05"<?= (date('H', $due) == 05) ? ' selected="selected"' : "" ?>>5 AM</option>
<option value="06"<?= (date('H', $due) == 06) ? ' selected="selected"' : "" ?>>6 AM</option>
<option value="07"<?= (date('H', $due) == 07) ? ' selected="selected"' : "" ?>>7 AM</option>
<option value="08"<?= (date('H', $due) == 08) ? ' selected="selected"' : "" ?>>8 AM</option>
<option value="09"<?= (date('H', $due) == 09) ? ' selected="selected"' : "" ?>>9 AM</option>
<option value="00"<?= (date('H', $due) == 0) ? ' selected="selected"' : "" ?>>Midnight</option>
<option value="01"<?= (date('H', $due) == 1) ? ' selected="selected"' : "" ?>>1 AM</option>
<option value="02"<?= (date('H', $due) == 2) ? ' selected="selected"' : "" ?>>2 AM</option>
<option value="03"<?= (date('H', $due) == 3) ? ' selected="selected"' : "" ?>>3 AM</option>
<option value="04"<?= (date('H', $due) == 4) ? ' selected="selected"' : "" ?>>4 AM</option>
<option value="05"<?= (date('H', $due) == 5) ? ' selected="selected"' : "" ?>>5 AM</option>
<option value="06"<?= (date('H', $due) == 6) ? ' selected="selected"' : "" ?>>6 AM</option>
<option value="07"<?= (date('H', $due) == 7) ? ' selected="selected"' : "" ?>>7 AM</option>
<option value="08"<?= (date('H', $due) == 8) ? ' selected="selected"' : "" ?>>8 AM</option>
<option value="09"<?= (date('H', $due) == 9) ? ' selected="selected"' : "" ?>>9 AM</option>
<option value="10"<?= (date('H', $due) == 10) ? ' selected="selected"' : "" ?>>10 AM</option>
<option value="11"<?= (date('H', $due) == 11) ? ' selected="selected"' : "" ?>>11 AM</option>
<option value="12"<?= (date('H', $due) == 12) ? ' selected="selected"' : "" ?>>12 Noon</option>
@@ -188,7 +188,8 @@
<dt><label for="check_desc">Checklist item:</label></dt>
<dd>
<input type="text" size="10" name="check_desc" id="check_desc" />&nbsp;&nbsp;
<input type="button" name="add_checklist_item" id="add_checklist_item" value="Add Checklist Item" />
<button name="add_checklist_item" id="add_checklist_item">Add Checklist Item</button>
<?php /*<input type="button" name="add_checklist_item" id="add_checklist_item" value="Add Checklist Item" /> */ ?>
</dd>
</dl>
<?php $this->load->view('task/checklist_view'); ?>
@@ -202,7 +203,8 @@
<dd>
<textarea rows="10" cols="80" name="comment" id="comment"></textarea>
<br />
<input type="button" name="add_task_comment" id="add_task_comment" value="Submit comment" />
<button name="add_task_comment" id="add_task_comment">Submit Comment</button>
<?php /*<input type="button" name="add_task_comment" id="add_task_comment" value="Submit comment" />*/ ?>
</dd>
</dl>
<?php $this->load->view('task/comments_view'); ?>

+ 268
- 0
build.xml View File

@@ -0,0 +1,268 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="animeclient" default="full-build">
<!-- By default, we assume all tools to be on the $PATH -->
<property name="pdepend" value="pdepend"/>
<property name="phpcpd" value="phpcpd"/>
<property name="phpcs" value="phpcs"/>
<property name="phploc" value="phploc"/>
<property name="phpmd" value="phpmd"/>
<property name="phpunit" value="phpunit"/>
<property name="sonar" value="sonar-runner"/>

<!-- Use this when the tools are located as PHARs in build/tools
<property name="pdepend" value="build/tools/pdepend.phar"/>
<property name="phpcpd" value="build/tools/phpcpd.phar"/>
<property name="phpcs" value="build/tools/phpcs.phar"/>
<property name="phpdox" value="build/tools/phpdox.phar"/>
<property name="phploc" value="build/tools/phploc.phar"/>
<property name="phpmd" value="build/tools/phpmd.phar"/>
<property name="phpunit" value="build/tools/phpunit.phar"/> -->

<!-- Use this when the tools are managed by Composer in vendor/bin
<property name="pdepend" value="vendor/bin/pdepend"/>
<property name="phpcpd" value="vendor/bin/phpcpd"/>
<property name="phpcs" value="vendor/bin/phpcs"/>
<property name="phpdox" value="vendor/bin/phpdox"/>
<property name="phploc" value="vendor/bin/phploc"/>
<property name="phpmd" value="vendor/bin/phpmd"/>
<property name="phpunit" value="vendor/bin/phpunit"/> -->

<target name="full-build"
depends="prepare,static-analysis,phpunit,sonar,-check-failure"
description="Performs static analysis, runs the tests, and generates project documentation"/>

<target name="full-build-parallel"
depends="prepare,static-analysis-parallel,phpunit, -check-failure"
description="Performs static analysis (executing the tools in parallel), runs the tests, and generates project documentation"/>

<target name="quick-build"
depends="prepare,lint,phpunit-no-coverage"
description="Performs a lint check and runs the tests (without generating code coverage reports)"/>

<target name="static-analysis"
depends="lint,phploc-ci,pdepend,phpcs-ci,phpcpd-ci"
description="Performs static analysis" />

<!-- Adjust the threadCount attribute's value to the number of CPUs -->
<target name="static-analysis-parallel"
description="Performs static analysis (executing the tools in parallel)">
<parallel threadCount="2">
<sequential>
<antcall target="pdepend"/>
</sequential>
<antcall target="lint"/>
<antcall target="phpcpd-ci"/>
<antcall target="phpcs-ci"/>
<antcall target="phploc-ci"/>
</parallel>
</target>

<target name="clean"
unless="clean.done"
description="Cleanup build artifacts">
<delete dir="build/api"/>
<delete dir="build/coverage"/>
<delete dir="build/logs"/>
<delete dir="build/pdepend"/>
<property name="clean.done" value="true"/>
</target>

<target name="prepare"
unless="prepare.done"
depends="clean"
description="Prepare for build">
<mkdir dir="build/api"/>
<mkdir dir="build/coverage"/>
<mkdir dir="build/logs"/>
<mkdir dir="build/pdepend"/>
<property name="prepare.done" value="true"/>
</target>

<target name="lint"
unless="lint.done"
description="Perform syntax check of sourcecode files">
<apply executable="php" taskname="lint">
<arg value="-l" />

<fileset dir="application">
<include name="**/*.php" />
<exclude name="logs/*.php" />
<exclude name="config/**/*.php" />
<exclude name="errors/*.php" />
<exclude name="third_party/**/*.php" />
<exclude name="views/**/*.php" />
<modified />
</fileset>

<fileset dir="tests">
<include name="**/*.php" />
<modified />
</fileset>
</apply>

<property name="lint.done" value="true"/>
</target>

<target name="phploc"
unless="phploc.done"
description="Measure project size using PHPLOC and print human readable output. Intended for usage on the command line.">
<exec executable="${phploc}" taskname="phploc">
<arg value="--count-tests" />
<arg path="application/controllers" />
<arg path="application/models" />
<arg path="application/libraries" />
<arg path="application/core" />
<arg path="application/hooks" />
<arg path="tests" />
</exec>

<property name="phploc.done" value="true"/>
</target>

<target name="phploc-ci"
unless="phploc.done"
depends="prepare"
description="Measure project size using PHPLOC and log result in CSV and XML format. Intended for usage within a continuous integration environment.">
<exec executable="${phploc}" taskname="phploc">
<arg value="--count-tests" />
<arg value="--log-csv" />
<arg path="build/logs/phploc.csv" />
<arg value="--log-xml" />
<arg path="build/logs/phploc.xml" />
<arg path="application/controllers" />
<arg path="application/models" />
<arg path="application/libraries" />
<arg path="application/core" />
<arg path="application/hooks" />
<arg path="tests" />
</exec>

<property name="phploc.done" value="true"/>
</target>

<target name="pdepend"
unless="pdepend.done"
depends="prepare"
description="Calculate software metrics using PHP_Depend and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${pdepend}" taskname="pdepend">
<arg value="--jdepend-xml=build/logs/jdepend.xml" />
<arg value="--jdepend-chart=build/pdepend/dependencies.svg" />
<arg value="--overview-pyramid=build/pdepend/overview-pyramid.svg" />
<arg path="application" />
</exec>

<property name="pdepend.done" value="true"/>
</target>

<target name="phpcs"
unless="phpcs.done"
description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${phpcs}" taskname="phpcs">
<arg value="--standard=PSR2" />
<arg value="--extensions=php" />
<arg value="--ignore=autoload.php" />
<arg path="application/controllers" />
<arg path="application/models" />
<arg path="application/libraries" />
<arg path="application/core" />
<arg path="application/hooks" />
<arg path="tests" />
</exec>

<property name="phpcs.done" value="true"/>
</target>

<target name="phpcs-ci"
unless="phpcs.done"
depends="prepare"
description="Find coding standard violations using PHP_CodeSniffer and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${phpcs}" output="/dev/null" taskname="phpcs">
<arg value="--report=checkstyle" />
<arg value="--report-file=build/logs/checkstyle.xml" />
<arg value="--standard=PSR2" />
<arg value="--extensions=php" />
<arg value="--ignore=autoload.php" />
<arg path="application/controllers" />
<arg path="application/models" />
<arg path="application/libraries" />
<arg path="application/core" />
<arg path="application/hooks" />
<arg path="tests" />
</exec>

<property name="phpcs.done" value="true"/>
</target>

<target name="phpcpd"
unless="phpcpd.done"
description="Find duplicate code using PHPCPD and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${phpcpd}" taskname="phpcpd">
<arg path="application/controllers" />
<arg path="application/models" />
<arg path="application/libraries" />
<arg path="application/core" />
<arg path="application/hooks" />
</exec>

<property name="phpcpd.done" value="true"/>
</target>

<target name="phpcpd-ci"
unless="phpcpd.done"
depends="prepare"
description="Find duplicate code using PHPCPD and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${phpcpd}" taskname="phpcpd">
<arg value="--log-pmd" />
<arg path="build/logs/pmd-cpd.xml" />
<arg path="application/controllers" />
<arg path="application/models" />
<arg path="application/libraries" />
<arg path="application/core" />
<arg path="application/hooks" />
</exec>

<property name="phpcpd.done" value="true"/>
</target>

<target name="phpunit"
unless="phpunit.done"
depends="prepare"
description="Run unit tests with PHPUnit">
<exec executable="${phpunit}" resultproperty="result.phpunit" taskname="phpunit">
<arg value="--configuration"/>
<arg path="build/phpunit.xml"/>
</exec>

<property name="phpunit.done" value="true"/>
</target>

<target name="phpunit-no-coverage"
unless="phpunit.done"
depends="prepare"
description="Run unit tests with PHPUnit (without generating code coverage reports)">
<exec executable="${phpunit}" failonerror="true" taskname="phpunit">
<arg value="--configuration"/>
<arg path="build/phpunit.xml"/>
<arg value="--no-coverage"/>
</exec>

<property name="phpunit.done" value="true"/>
</target>

<target name="sonar"
depends="phpunit">
<exec executable="${sonar}" taskname="sonar"/>
<property name="sonar.done" value="true"/>
</target>

<target name="-check-failure">
<fail message="PHPUnit did not finish successfully">
<condition>
<not>
<equals arg1="${result.phpunit}" arg2="0"/>
</not>
</condition>
</fail>
</target>
</project>


+ 48
- 0
build/phpunit.xml View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit
colors="true"
stopOnFailure="false"
bootstrap="../tests/bootstrap.php">
<php>
<server name="SERVER_NAME" value="http://example.com" />
<server name="REMOTE_ADDR" value="127.0.0.1" />
<server name="HTTP_USER_AGENT" value="PHPUnit" />
</php>
<filter>
<whitelist>
<directory suffix=".php">../application/controllers</directory>
<directory suffix=".php">../application/core</directory>
<directory suffix=".php">../application/libraries</directory>
<directory suffix=".php">../application/models</directory>
<directory suffix=".php">../application/helpers</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="ControllerTests">
<directory suffix=".php">../tests/controllers</directory>
</testsuite>
<testsuite name="ExtensionTests">
<directory suffix=".php">../tests/core</directory>
</testsuite>
<testsuite name="HelperTests">
<directory suffix=".php">../tests/helpers</directory>
</testsuite>
<testsuite name="LibTests">
<directory suffix=".php">../tests/libs</directory>
</testsuite>
<testsuite name="ModelTests">
<directory suffix=".php">../tests/models</directory>
</testsuite>
<testsuite name="SystemTests">
<directory suffix=".php">../tests/system</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-html" target="coverage"/>
<log type="coverage-clover" target="logs/clover.xml"/>
<log type="coverage-crap4j" target="logs/crap4j.xml"/>
<log type="coverage-xml" target="logs/coverage" />
<log type="junit" target="logs/junit.xml" logIncompleteSkipped="false"/>
</logging>
</phpunit>

+ 6
- 0
sonar-project.properties View File

@@ -0,0 +1,6 @@
sonar.projectKey=todo
sonar.projectName=Tim's Todo
sonar.projectVersion=1.0
sonar.sources=application/controllers,application/models,application/libraries,application/core,application/hooks
sonar.php.coverage.reportPath=build/logs/clover.xml
sonar.php.tests.reportPath=build/logs/junit.xml

+ 4
- 4
system/core/Common.php View File

@@ -274,7 +274,7 @@ if ( ! function_exists('config_item'))

if ( ! isset($_config_item[$item]))
{
$config =& get_config();
$config = get_config();

if ( ! isset($config[$item]))
{
@@ -514,16 +514,16 @@ if ( ! function_exists('remove_invisible_characters'))
function remove_invisible_characters($str, $url_encoded = TRUE)
{
$non_displayables = array();
// every control character except newline (dec 10)
// carriage return (dec 13), and horizontal tab (dec 09)
if ($url_encoded)
{
$non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15
$non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31
}
$non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127

do

+ 1
- 1
system/core/Config.php View File

@@ -60,7 +60,7 @@ class CI_Config {
*/
function __construct()
{
$this->config =& get_config();
$this->config = get_config();
log_message('debug', "Config Class Initialized");

// Set the base_url automatically if none was provided

+ 1
- 1
system/core/Lang.php View File

@@ -78,7 +78,7 @@ class CI_Lang {
return;
}

$config =& get_config();
$config = get_config();

if ($idiom == '')
{

+ 1
- 1
system/libraries/Log.php View File

@@ -37,7 +37,7 @@ class CI_Log {
*/
public function __construct()
{
$config =& get_config();
$config = get_config();

$this->_log_path = ($config['log_path'] != '') ? $config['log_path'] : APPPATH.'logs/';


+ 6
- 8
tests/env/autoloader.php View File

@@ -20,15 +20,13 @@ spl_autoload_register(function($class) {
$exact_file = "{$path}{$class}.php";
$lower_file = $path . mb_strtolower($class) . ".php";

if (file_exists($lower_file))
foreach([$lower_file, $exact_file] as $file)
{
require_once($lower_file);
return;
}
else if (file_exists($exact_file))
{
require_once($exact_file);
return;
if (file_exists($file))
{
require_once($file);
return;
}
}
}
});

+ 10
- 10
tests/phpunit.xml View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit
colors="true"
stopOnFailure="false"
<phpunit
colors="true"
stopOnFailure="false"
bootstrap="bootstrap.php">
<php>
<server name="SERVER_NAME" value="http://example.com" />
@@ -10,13 +10,13 @@
<server name="HTTP_USER_AGENT" value="PHPUnit" />
</php>
<filter>
<blacklist>
<directory suffix=".php">../application/third_party</directory>
<directory suffix=".php">../application/config</directory>
<directory suffix=".php">../application/views</directory>
<directory suffix=".php">../system</directory>
<directory suffix=".php">.</directory>
</blacklist>
<whitelist>
<directory suffix=".php">../application/controllers</directory>
<directory suffix=".php">../application/core</directory>
<directory suffix=".php">../application/libraries</directory>
<directory suffix=".php">../application/models</directory>
<directory suffix=".php">../application/helpers</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="ControllerTests">

+ 19
- 19
web/css/todo.css View File

@@ -175,7 +175,7 @@ section{



input[type="submit"], input[type="button"]{
input[type="submit"], input[type="button"], button{
background:url('/images/bgs/Title.png');
color:#fff;
padding:0.5em;
@@ -601,7 +601,7 @@ select#friends option{
vertical-align:top;
display:inline-block;
}
header nav{
width:80%;
}
@@ -609,7 +609,7 @@ select#friends option{
section, footer, nav{
border:0;
}
dt{
text-align:right;
padding-right:0.5em;
@@ -633,7 +633,7 @@ select#friends option{
border-radius:5px;
margin-left:0.35%;
}
#pagination strong{
letter-spacing:.5em;
margin-left:.5em;
@@ -658,34 +658,34 @@ select#friends option{
vertical-align:top;
background:transparent;
}
.left{
border-radius:0;
text-align:left;
width:15%;
}
#home .left{
width:74%;
}
.left form{
width:100%;
margin:0 auto;
}
.right{
border-bottom-left-radius:5px;
padding-top:0;
margin-left:.25%;
width:83%;
}
#home .right{
width:22%;
}
dt{
width:13%;
}
@@ -693,25 +693,25 @@ select#friends option{
#left_nav li{
display:block;
}
fieldset dt, fieldset dd{
display:inline-block;
vertical-align:top;
margin:.5% 0;
}
strong {
font-weight:bold;
}
#task_view dt, th a{
font-weight:bold;
}
.error{
font-weight:300;
}
#task_comment_list dt{
width:25%;
padding:.5em;
@@ -721,12 +721,12 @@ select#friends option{
width:70%;
padding:.5em;
}
.immediate, td.immediate, .overdue td{
font-weight:bold;
font-style:italic;
}
.overdue td{
font-weight:bold;
}
@@ -736,7 +736,7 @@ select#friends option{
vertical-align:top;
margin:.5em auto;
}
#home .right dt, #home .right dd{
width:45%;
display:inline-block;

Loading…
Cancel
Save