[PHPUnit] Testing output

Test contains not only unit test, integration test, but also the output of screen, including files etc.

For example, with the function exceptOutputString, we can test the string output by echo or print.

class OutputTest extends PHPUnit_Framework_TestCase
    public function testExpectFooActualFoo()
        $this->outputString();    // Call my local function
        $this->expectOutputString('Hello world!');    // Comparaison

    // local function 
    private function outputString()
        echo "Hello world!";

Ref. Methods for output testing

[French Vocabulary] maquette


n. f
1模型; 雏型; 设计模型; 原型
2草图, 画稿; (封面、插图、广告画等的)彩色原图
3(印刷物或版面的)设计, 设计方案

faire des maquettes d’avions做飞机模型

ref. frdic

[JS Practice] Array Appender

Title :

Array Appender


You are the greatest chef on earth. No one boils eggs like you! Your restaurant is always full of guests, who love your boiled eggs. But when there is a greater order of boiled eggs, you need some time, because you have only one pot for your job. How much time do you need?

Your Task

Write a function called appendArrays that appends the items from array 2 onto array 1, returning the newly formed array.

For example if your 2 arrays were:

var array1 = [a,b,c]
var array2 = [1,2,3]

After using your appendArrays function, the result should be[a,b,c,1,2,3]

Your function should also be able to handle nested arrays.

For example, combining array [['x','x'],'B'] with array['c','D'] should return [['x','x'],'B','c','D'].

Your solution should account for a situation for either the first or second inputs aren’t actually arrays.

// basic test
Test.assertSimilar(appendArrays(['this'],['that']), ['this','that'])

// second input is not an array
Test.assertSimilar(appendArrays([1,2], [1]), [1,2,1])

// first input is not an array
Test.assertSimilar(appendArrays([2], [1,1,1]), [2,1,1,1])

Continue reading

[samba] Configuration File, options, add a samba user

A simple blog, to be completed.

- 1st point :

An example of samba configuration file structure :

    workgroup = METRAN
    encrypt passwords = yes
    wins support = yes
    log level = 1 
    max log size = 1000
    read only = no
    browsable = no
    map archive = yes
    path = /var/tmp
    printable = yes
    min print space = 2000
    browsable = yes
    read only = yes
    path = /usr/local/samba/tmp


- 2nd point :

There is a very interesting option in samba configuration file is : include

We can do as in Apache configuration file :

    include = /usr/local/samba/lib/smb.conf.%m

Which is more interesting for multiple applications is that, if the configuration file specified does not exist, the option is ignored. It won’t raise an error if one of them not exist.


- 3rd point :

Command to add a samba user :

smbpasswd -a your_username