Created
August 29, 2016 16:18
-
-
Save jlamim/2cb327dc3728ee0332858cf48757e129 to your computer and use it in GitHub Desktop.
Testes unitários com PHPUnit no CodeIgniter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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