phpixie/sylph

dev-master / 2.x-dev 2013-05-02 21:27 UTC

This package is auto-updated.

Last update: 2024-09-13 02:04:20 UTC


README

一个简单易用的数组到类Stubber。大大提高编写类Stub的效率。以下是一个快速示例

    $this->sylph = new \PHPixie\Sylph();
    $flowers = 7; //Will use it in an anonymous method later on
    $fairy = $this->sylph->cast(array(
        'name' => 'Tinkerbell',
        'likes' => array(
            'flying'  => true,
            'dancing' => true
        ),
        'pick_flowers' => function($picked) use($flowers){
            return $picked + $flowers;
        },
        'friend' => $this->sylph->cast(array(
            'name' => 'Trixie'
        ))
    ));
    
    $this->assertEquals('Tinkerbell', $fairy->name);
    $this->assertEquals(true, $fairy->likes['flying']);
    $this->assertEquals(true, $fairy->likes['dancing']);
    $this->assertEquals(10, $fairy->pick_flowers(3));
    $this->assertEquals('Trixie', $fairy->friend->name);