PHP code example of blainesch / li3_unit

1. Go to this page and download the library: Download blainesch/li3_unit library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

blainesch / li3_unit example snippets


	Libraries::add('li3_unit');


namespace app\tests\cases;

use li3_unit\test\Unit;

class SampleTest extends Unit {

	public function testSomething() {
		$this->assertCount(3, array('foo', 'bar', 'baz'));
	}

}


namespace app\tests\cases\controllers;

use li3_unit\test\ControllerUnit;

class UsersControllerTest extends ControllerUnit {

	public $controller = 'app\\controllers\\UsersController';

	public function testSomething() {
		$data = $this->call('profile', array(
			'params' => array(
				'name' => 'Blaine',
			)
		));

		$user = $data['user'];

		$this->assertEqual('Blaine', $user->username);
	}

}


namespace app\tests\cases\extensions\helper;

use li3_unit\test\HelperUnit;

class ProseTest extends HelperUnit {

	public $prose;

	public function setUp() {
		$this->prose = $this->create('Prose');
	}

	public function testFourEightStarStatement() {
		$expected = 'Amazing';
		$this->assertEqual($expected, $this->prose->starStatement(4.8));
	}

}


namespace app\tests\cases\models;

use li3_unit\test\ModelUnit;

class UsersTest extends ModelUnit {

	public $model = 'app\\models\\Users';

	public $defaultData = array(
		'id' => '10',
		'fname' => 'Blaine',
		'lname' => 'Smith',
	);

	public function testName() {
		$user = $this->create(array(
			'fname' => 'Blaine',
			'lname' => 'Schmeisser',
		));
		$expected = 'Blaine Schmeisser';
		$this->assertEqual($expected, $user->fullName());
	}

}