1. Go to this page and download the library: Download bingher/think-test 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/ */
bingher / think-test example snippets
use bingher\ThinkTest\ThinkTest;
class Test extends ThinkTest
{
public function testTap()
{
$result = tap('world');
$this->assertEquals($result, 'world');
$result = tap('world', null);
$this->assertEquals($result, 'world');
$result = tap(
'world',
function ($v) {
$v = 'hello ' . $v;
}
);
$this->assertEquals($result, 'world');
$result = tap(
'world',
function (&$v) {
$v = 'hello ' . $v;
}
);
$this->assertEquals($result, 'hello world');
}
}
namespace bingher\test;
use bingher\ThinkTest\ThinkTest;
class Test extends ThinkTest
{
public function testTap()
{
$result = tap('world');
$this->assertEquals($result, 'world');
$result = tap('world', null);
$this->assertEquals($result, 'world');
$result = tap(
'world',
function ($v) {
$v = 'hello ' . $v;
}
);
$this->assertEquals($result, 'world');
$result = tap(
'world',
function (&$v) {
$v = 'hello ' . $v;
}
);
$this->assertEquals($result, 'hello world');
}
}
namespace bingher\test;
use bingher\ThinkTest\ThinkTest;
class HelloTest extends ThinkTest
{
public function testSay()
{
$hello = new Hello;
//use prop function get protected properties
$name = $this->prop($hello, 'name');
$this->assertEquals($name, 'bingher');
$result = $hello->say();
$this->assertEquals($result, 'hello bingher');
}
public function testSmile()
{
$hello = new Hello('mondy');
//use prop function get protected properties
$name = $this->prop($hello, 'name');
$this->assertEquals($name, 'mondy');
//use call function run protected function
$result = $this->call($hello, 'smile');
$this->assertEquals($result, 'hello mondy :)');
//add params
$result = $this->call($hello, 'smile', [2]);
$this->assertEquals($result, 'hello mondy :):)');
//use prop function set protected properties value
$this->prop($hello, 'name', 'everyone');
$name = $this->prop($hello, 'name');
$this->assertEquals($name, 'everyone');
}
}
shell
./vendor/bin/tpt.bat ./test/Test.php
shell
./vendor/bin/tpt ./test/Test.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.