PHP code example of graychen / generatestring

1. Go to this page and download the library: Download graychen/generatestring 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/ */

    

graychen / generatestring example snippets

 php

namespace graychen\Test;

use graychen\generatestring;

class generatestringTest extends \PHPUnit_Framework_TestCase
{
    private $string;

    public function setUp()
    {
        $this->string=new generatestring();
    }
    public function testGetchars()
    {
        $result = $this->string->getchars("a", 10);
        $this->assertEquals('aaaaaaaaaa', $result);
    }

    public function testGetchars_t()
    {
        $result = $this->string->getchars_t("abc", 10);
        $this->assertEquals('abcabcabcabcabcabcabcabcabcabc', $result);
    }

    public function testGetchars_p()
    {
        $result = $this->string->getchars_p("abc", 10);
        $this->assertEquals('abcabcabcabcabcabcabcabcabcabc', $result);
    }

    public function testGetcharscmp()
    {
        $result = $this->string->getcharscmp("abc", 10);
        $this->assertEquals('abcabcabca', $result);
    }

    public function testGetchars_s()
    {
        $result = $this->string->getchars_s("abc", 10);
        $this->assertEquals('abcabcabcabcabcabcabcabcabcabc', $result);
    }
}