Location: PHPKode > projects > TeamSpeak3 ChannelWatcher > devMX-TeamSpeak3-ChannelWatcher-f5257dd/tests/src/devmx/ChannelWatcher/Rule/SaveChildsRuleTest.php
<?php

namespace devmx\ChannelWatcher\Rule;
/**
 * Test class for SaveParentRule.
 * Generated by PHPUnit on 2012-05-21 at 13:54:53.
 */
class SaveChildsRuleTest extends \PHPUnit_Framework_TestCase
{

    /**
     * @covers devmx\ChannelWatcher\Rule\SaveChildsRule::filter
     * @todo Implement testFilter().
     */
    public function testFilter_simple()
    {
        $rule = new SaveChildsRule();
        $channelList = array(
            1 => array(
                'cid' => 1,
                'pid' => 0,
                '__delete' => false,
            ),
            2 => array(
                'cid' => 2,
                'pid' => 1,
                '__delete' => true,
            ),
            3 => array(
                'cid' => 3,
                'pid' => 1,
                '__delete' => true,
            )
        );
        $expected = $channelList;
        $expected[2]['__delete'] = false;
        $expected[3]['__delete'] = false;
        $this->assertEquals($expected, $rule->filter($channelList));
    }
    
    /**
     * @covers devmx\ChannelWatcher\Rule\SaveChildsRule::filter
     * @todo Implement testFilter().
     */
    public function testFilter_nested_noExplicitLevel()
    {
        $rule = new SaveChildsRule();
        $channelList = array(
            1 => array(
                'cid' => 1,
                'pid' => 0,
                '__delete' => false,
            ),
            2 => array(
                'cid' => 2,
                'pid' => 1,
                '__delete' => true,
            ),
            3 => array(
                'cid' => 3,
                'pid' => 2,
                '__delete' => true,
            )
        );
        $expected = $channelList;
        $expected[2]['__delete'] = false;
        $expected[3]['__delete'] = false;
        $this->assertEquals($expected, $rule->filter($channelList));
    }
    
    /**
     * @covers devmx\ChannelWatcher\Rule\SaveChildsRule::filter
     * @todo Implement testFilter().
     */
    public function testFilter_nested_ExplicitNoLevel()
    {
        $rule = new SaveChildsRule();
        $channelList = array(
            1 => array(
                'cid' => 1,
                'pid' => 0,
                '__delete' => false,
            ),
            2 => array(
                'cid' => 2,
                'pid' => 1,
                '__delete' => true,
            ),
            3 => array(
                'cid' => 3,
                'pid' => 2,
                '__delete' => true,
            )
        );
        $rule->setLevel(-1);
        $expected = $channelList;
        $expected[2]['__delete'] = false;
        $expected[3]['__delete'] = false;
        $this->assertEquals($expected, $rule->filter($channelList));
    }
    
    /**
     * @covers devmx\ChannelWatcher\Rule\SaveChildsRule::filter
     * @todo Implement testFilter().
     */
    public function testFilter_nested_level()
    {
        $rule = new SaveChildsRule();
        $channelList = array(
            1 => array(
                'cid' => 1,
                'pid' => 0,
                '__delete' => false,
            ),
            2 => array(
                'cid' => 2,
                'pid' => 1,
                '__delete' => true,
            ),
            3 => array(
                'cid' => 3,
                'pid' => 2,
                '__delete' => true,
            )
        );
        $rule->setLevel(1);
        $expected = $channelList;
        $expected[2]['__delete'] = false;
        $expected[3]['__delete'] = true;
        $this->assertEquals($expected, $rule->filter($channelList));
    }
    
    /**
     * @covers devmx\ChannelWatcher\Rule\SaveChildsRule::filter
     * @todo Implement testFilter().
     */
    public function testFilter_nested_deepLevel()
    {
        $rule = new SaveChildsRule();
        $channelList = array(
            1 => array(
                'cid' => 1,
                'pid' => 0,
                '__delete' => false,
            ),
            2 => array(
                'cid' => 2,
                'pid' => 1,
                '__delete' => true,
            ),
            3 => array(
                'cid' => 3,
                'pid' => 2,
                '__delete' => true,
            ),
            4 => array(
                'cid' => 4,
                'pid' => 3,
                '__delete' => true,
            ),
            5 => array(
                'cid' => 5,
                'pid' => 4,
                '__delete' => true
            ),
            6 => array(
                'cid' => 6,
                'pid' => 4,
                '__delete' => true,
            ),
            7 => array(
                'cid' => 7,
                'pid' => 2,
                '__delete' => true,
            ),
        );
        $rule->setLevel(2);
        $expected = $channelList;
        $expected[2]['__delete'] = false;
        $expected[3]['__delete'] = false;
        $expected[7]['__delete'] = false;
        $this->assertEquals($expected, $rule->filter($channelList));
    }

}

?>
Return current item: TeamSpeak3 ChannelWatcher