16.2 Creating a Test
Let’s take a look at a test case, fortunately Laravel has included an example test case for us!
1 <?php
2
3 // application/tests/example.test.php
4
5 class TestExample extends PHPUnit_Framework_TestCase {
6
7 /**
8 * Test that a given condition is met.
9 *
10 * @return void
11 */
12 public function testSomethingIsTrue()
13 {
14 $this->assertTrue(true);15 }
16
17 }
As you can see we create our test cases in a file with the extension test.php, the name of the
class must start with the word Test and it must extend the class PHPUnit_Framework_TestCase.
These are limitations set not by Laravel, but by the PHPUnit software.
A PHPUnit test case may contain any number of tests, as camel-cased actions, prefixed with the
word test. Our tests can contain a number of different assertions that decide whether our tests
will pass or fail.
A full list of assertions can be found on the PHPUnit documentation website³.
Yasar Khan
Skills Laravel
Qualifications :-Location :-Dehradun,Dehradun,Uttarakhand,India
Description:- Hi i am yasar working as web developer since last 3 years.
Explore