A clean way of integrating PHPUnit 3.5.x with CodeIgniter 2.x

Jan 20, 2012

Now a days, my default choice of framework is always Zend Framework. However, I have to maintain a couple live projects in CodeIgniter from early days. I feel its very important to have tests around critical applications, so I have attempted a couple times to integrate PHPUnit with CodeIgniter but failed every time – well, until now.

I’ve managed it this time with hooks. It provides a clean way of bootstrapping the framework and then performing tests on the Model layer – for me testing the model layer has been sufficient. The use is very simple as it does not require any change in how a regular CodeIgniter application is built.

Grab the code from github.

Example – /tests/PostTest.php

<?php

class PostTest extends PHPUnit_Framework_TestCase
{
    private $CI;

    public function setUp()
    {
        $this->CI = &get_instance();
        $this->CI->load->database('testing');
    }

    public function testGetsAllPosts()
    {
        $this->CI->load->model('post');
        $posts = $this->CI->post->getAll();
        $this->assertEquals(1, count($posts));
    }
}

Read the rest of this article »

3 Comments

To me design is…

Jan 15, 2012

A great compilation by Vostok Studios on what great designers think about design.

No Comments

Painless Ruby and Rails installation on Ubuntu/Mint

Jun 3, 2011

It took me an hour to properly install the latest versions of ruby, rails and its mysql binder. Although its less than a 5 mins task, I had to search in forums, blogs to deal with the various errors. So just posting this so its easy for someone else to get done with this in 5 mins.

1. Open Terminal and install RVM (Ruby Version Manager)

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

2. Enter the following in ~/.bash_profile and/or ~/.bashrc (replace YOUR USER NAME with the username you’re logged in with):

[[ -s "/home/YOUR USER NAME/.rvm/scripts/rvm" ]] && source "/home/YOUR USER NAME/.rvm/scripts/rvm"  # This loads RVM into a shell session.

3. Install Ruby 1.9.2

rvm install 1.9.2

Read the rest of this article »

No Comments

Setting up central Mercurial server in Ubuntu

May 8, 2011

Mercurial

It’s been a while since we’ve been thinking about moving to Mercurial from Subversion at our company. We were convinced about the benefits of DVCS and chose Mercurial over Git. However, due to pressure at work and some procrastination, the move was delayed a couple times. Finally, today we had the move and the team is already up to speed with it.

Although it’s quite simple to install it in a central server, the different articles on the web had me confused with too many options or with a different distro than Ubuntu. So, here is a dead simple list of things to do for installing Mercurial centrally for your dev team.

Read the rest of this article »

18 Comments

2011

Jan 7, 2011

First, a very happy new year to everybody!!! The last year has showed me the ups and downs of life and I believe 2011 will be a great year. Some of my wishes in 2011 would be:

  • Re-shaping my company to become a major OSS based company in Bangladesh
  • Doing something meaningful for my country
  • Learning Ruby and related frameworks (Rails, Cucumber, etc)
  • Spending more time my family
  • Having more fun with my friends
  • Living a healthy life
1 Comment