Review: PHPUnit Essentials

I recently got my hands on the book “PHPUnit Essentials” and decided to do a review.

The book offers a wide variety of information about PHPUnit. At the very beginning it provides insights how to install PHPUnit and how to set up a development environment. Further, it elaborates on the question why to do tests and how to write code that can be tested easier. Finally it reaches its culmination with more business oriented techniques of “Functional Tests in the Browser using Selenium” and “Continuous Integration”.

Weiterlesen

Create a private mediawiki with some public pages

Per site restriction is not possible by default in mediawiki, but there are many ways to create such environment mostly with using extensions. The most easy and flexible way without extensions is described on this page: http://meta.wikimedia.org/wiki/Regexp_wgWhitelistRead

It’s simply done by editing the file include/Title.php and find the line that looks like this in the function userCanRead(). In my version 1.16 it looked minimal different than at the link example:

$name = $this->getPrefixedText();
$dbName = $this->getPrefixedDBKey();
// Check with and without underscores
if ( 
  in_array( $name, $wgWhitelistRead, true ) || 
  in_array( $dbName, $wgWhitelistRead, true ) 
){
  return true;
}

Replace them with the following lines:

$name = $this->getPrefixedText();
if ( is_array($wgWhitelistRead) ) {
  for ($i=0; $i<count($wgWhitelistRead); $i++) {
    if (preg_match($wgWhitelistRead[$i],$name)) {
      return true;
    }
  }
}

Then you are able to use regular expressions in your $wgWhitelistRead which offers great opportunities.
The following code allows non-namespaced pages, Special:Search, Special:Categories pages and several Namespaces like: Help:*, Image:*, User:* and Category:* to be seen by anonymous users.

$wgWhitelistRead = array (
  "/^[^:]*$/", 
  "/^Special:(Search|Categories)$/", 
  "/^(Help|Image|User|Category):/" 
);

If you really have a private Wiki you might also want to remove Search and Categories, as they list also your private pages.

Review: Codelobster PHP Edition

Contents

Introduction

I recently had the chance to take a look at the professional version of Codelobster PHP Edition. For those who may not know it: Codelobster is an IDE specialized on PHP development. Since HTML, CSS and JS are mostly always  needed when working with PHP it also includes good support for them.

The IDE is available in two different versions a free one and a professional one. While the free version features mostly everything one might know from other IDEs, the professional version has some neat support for the most famous PHP CMSs (Drupal, Joomla and WordPress), Frameworks (Symfony, CakePHP, CodeIgniter, facebook API, yii framework, smarty), jQuery and an SQL Manager to make the developers life even more easier, than by just using those frameworks.

General Facts –>

PHPUnit: use different dataset on every test in a testcase

PHPUnit offers the possibility to perform tests based in database fixtures. The common way is like described in the PHPUnit documentation.

But what if you just want to have a small and different dataset on every test?
Weiterlesen