Skip to content

Instantly share code, notes, and snippets.

@jlamim
Created August 29, 2016 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlamim/2cb327dc3728ee0332858cf48757e129 to your computer and use it in GitHub Desktop.
Save jlamim/2cb327dc3728ee0332858cf48757e129 to your computer and use it in GitHub Desktop.
Testes unitários com PHPUnit no CodeIgniter
<?php
class SampleTest extends PHPUnit_Framework_TestCase
{
private $CI;
public function setUp()
{
$this->CI = &get_instance();
}
public function testPushAndPop()
{
$stack = array();
$this->assertEquals(0, count($stack));
array_push($stack, 'foo');
$this->assertEquals('foo', $stack[count($stack)-1]);
$this->assertEquals(1, count($stack));
$this->assertEquals('foo', array_pop($stack));
$this->assertEquals(0, count($stack));
}
public function testValidEmail(){
$this->CI->load->helper('string');
$my_string = random_string('alnum',10);
$this->assertEquals(strlen($my_string), 8);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment