PHP code example of mikolajprzybysz / php-native-wrapper

1. Go to this page and download the library: Download mikolajprzybysz/php-native-wrapper 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/ */

    

mikolajprzybysz / php-native-wrapper example snippets


class SampleClass {
    /** @var Native */
    protected $native;
    public function __construct(Native $native){
        $this->native = $native;
    }
}

class SampleClass {
    /** @var Native */
    protected $native;
    public function setNative(Native $native){
        $this->native = $native;
    }
}

class SampleClass {
    /** @var Native */
    protected $native;
    public function sampleMethod(){
        return $native->time();
    }
}

class SampleClassTest extends \PHPUnit_Framework_TestCase {
    public function testSampleMethod(){
        $sampleTime = 123;
        $nativeMock = $this->getMock(Native::class);
        $nativeMock->expects($this->once())->method('time')->will($this->returnValue($sampleTime));
        $testObject = new SampleClass($nativeMock);
        $result = $testObject->sampleMethod();
        $this->assertEquals($sampleTime, $result);
    }
}

./vendor/bin/phpunit test/MockTest.php --bootstrap vendor/autoload.php

./vendor/bin/phpunit test/MockTest.php --bootstrap vendor/autoload.php