<commit_before><?php
/**
 * @group Vps_Component_Acl
 */
class Vps_Component_Acl_Test extends PHPUnit_Framework_TestCase
{
    private $_acl;
    private $_root;

    public function setUp()
    {
        Vps_Component_Data_Root::setComponentClass('Vps_Component_Acl_Root');
        $this->_root = Vps_Component_Data_Root::getInstance();

        $acl = new Vps_Acl();
        $this->_acl = $acl->getComponentAcl();
        $acl->addRole(new Zend_Acl_Role('test'));
    }

    public function testDefaultRule()
    {
        $this->assertFalse($this->_acl->isAllowed('test', 'Vpc_Basic_Empty_Component'));
        $this->assertFalse($this->_acl->isAllowed('guest', 'Vpc_Basic_Empty_Component'));
        $this->assertFalse($this->_acl->isAllowed(null, 'Vpc_Basic_Empty_Component'));
    }

    public function testAllowComponentAll()
    {
        $this->_acl->allowComponent('test', null);
        $this->assertFalse($this->_acl->isAllowed(null, 'Vpc_Basic_Empty_Component'));
        $this->assertTrue($this->_acl->isAllowed('test', 'Vpc_Basic_Empty_Component'));
        $this->assertTrue($this->_acl->isAllowed('test', 'Vps_Component_Acl_Root'));
    }

    public function testAllowComponent()
    {
        $this->_acl->allowComponent('test', 'Vps_Component_Acl_Empty2');
        $this->assertFalse($this->_acl->isAllowed(null, 'Vpc_Basic_Empty_Component'));
        $this->assertTrue($this->_acl->isAllowed('test', 'Vps_Component_Acl_Empty2'));
        $this->assertFalse($this->_acl->isAllowed('test', 'Vpc_Basic_Empty_Component'));
        $this->assertFalse($this->_acl->isAllowed('test', 'Vps_Component_Acl_Root'));
    }

    public function testAllowComponentChild()
    {
        $this->_acl->allowComponent('test', 'Vps_Component_Acl_TestComponent');
        $this->assertTrue($this->_acl->isAllowed('test', 'Vps_Component_Acl_TestComponent'));
        $this->assertTrue($this->_acl->isAllowed('test', 'Vpc_Basic_Empty_Component'));
    }

    public function testAllowComponentChildRoot()
    {
        $this->_acl->allowComponent('test', 'Vps_Component_Acl_Root');
        $this->assertTrue($this->_acl->isAllowed('test', 'Vps_Component_Acl_Root'));
        $this->assertTrue($this->_acl->isAllowed('test', 'Vpc_Basic_Empty_Component'));
        $this->assertTrue($this->_acl->isAllowed('test', 'Vps_Component_Acl_Empty2'));
        $this->assertTrue($this->_acl->isAllowed('test', 'Vps_Component_Acl_TestComponent'));
    }

    public function testHasAllowedChildComponents()
    {
        $this->assertFalse($this->_acl->hasAllowedChildComponents('test', $this->_root));
        $this->_acl->allowComponent('test', 'Vps_Component_Acl_TestComponent');
        $this->assertTrue($this->_acl->hasAllowedChildComponents('test', $this->_root));
    }

    public function testDynamicComponent()
    {
        $this->assertFalse($this->_acl->isAllowed('test', $this->_root));
        $this->_acl->allowComponent('test', 'Vps_Component_Acl_Root');
        $this->assertTrue($this->_acl->isAllowed('test', $this->_root));
        foreach ($this->_root->getChildComponents() as $c) {
            $this->assertTrue($this->_acl->isAllowed('test', $c));
        }
        $this->assertTrue($this->_acl->isAllowed('test', $this->_root->getComponentById('4')));
    }

    public function testDynamicComponent2()
    {
        $this->_acl->allowComponent('test', 'Vps_Component_Acl_TestComponent');
        $this->assertFalse($this->_acl->isAllowed('test', $this->_root));
        $this->assertFalse($this->_acl->isAllowed('test', $this->_root->getComponentById('1')));
        $this->assertTrue($this->_acl->isAllowed('test', $this->_root->getComponentById('3')));
        $this->assertTrue($this->_acl->isAllowed('test', $this->_root->getComponentById('4')));<commit_msg>Fix Test<commit_after><?php
/**
 * @group Vps_Component_Acl
 */
class Vps_Component_Acl_Test extends PHPUnit_Framework_TestCase
{
    private $_acl;
    private $_root;

    public function setUp()
    {
        Vps_Component_Data_Root::setComponentClass('Vps_Component_Acl_Root');
        $this->_root = Vps_Component_Data_Root::getInstance();

        $acl = new Vps_Acl();
        $this->_acl = $acl->getComponentAcl();
        $acl->addRole(new Zend_Acl_Role('test'));
    }

    public function testDefaultRule()
    {
        $this->assertFalse($this->_acl->isAllowed('test', 'Vpc_Basic_Empty_Component'));
        $this->assertFalse($this->_acl->isAllowed('guest', 'Vpc_Basic_Empty_Component'));
        $this->assertFalse($this->_acl->isAllowed(null, 'Vpc_Basic_Empty_Component'));
    }

    public function testAllowComponentAll()
    {
        $this->_acl->allowComponent('test', null);
        $this->assertFalse($this->_acl->isAllowed(null, 'Vpc_Basic_Empty_Component'));
        $this->assertTrue($this->_acl->isAllowed('test', 'Vpc_Basic_Empty_Component'));
        $this->assertTrue($this->_acl->isAllowed('test', 'Vps_Component_Acl_Root'));
    }

    public function testAllowComponent()
    {
        $this->_acl->allowComponent('test', 'Vps_Component_Acl_Empty2');
        $this->assertFalse($this->_acl->isAllowed(null, 'Vpc_Basic_Empty_Component'));
        $this->assertTrue($this->_acl->isAllowed('test', 'Vps_Component_Acl_Empty2'));
        $this->assertFalse($this->_acl->isAllowed('test', 'Vpc_Basic_Empty_Component'));
        $this->assertFalse($this->_acl->isAllowed('test', 'Vps_Component_Acl_Root'));
    }

    public function testAllowComponentChild()
    {
        $this->_acl->allowComponent('test', 'Vps_Component_Acl_TestComponent');
        $this->assertTrue($this->_acl->isAllowed('test', 'Vps_Component_Acl_TestComponent'));
        $this->assertTrue($this->_acl->isAllowed('test', 'Vpc_Basic_Empty_Component'));
    }

    public function testAllowComponentChildRoot()
    {
        $this->_acl->allowComponent('test', 'Vps_Component_Acl_Root');
        $this->assertTrue($this->_acl->isAllowed('test', 'Vps_Component_Acl_Root'));
        $this->assertTrue($this->_acl->isAllowed('test', 'Vpc_Basic_Empty_Component'));
        $this->assertTrue($this->_acl->isAllowed('test', 'Vps_Component_Acl_Empty2'));
        $this->assertTrue($this->_acl->isAllowed('test', 'Vps_Component_Acl_TestComponent'));
    }

    public function testHasAllowedChildComponents()
    {
        $this->assertEquals(0, count($this->_acl->getAllowedRecursiveChildComponents('test', $this->_root)));
        $this->_acl->allowComponent('test', 'Vps_Component_Acl_TestComponent');
        $this->assertEquals(1, count($this->_acl->getAllowedRecursiveChildComponents('test', $this->_root)));
    }

    public function testDynamicComponent()
    {
        $this->assertFalse($this->_acl->isAllowed('test', $this->_root));
        $this->_acl->allowComponent('test', 'Vps_Component_Acl_Root');
        $this->assertTrue($this->_acl->isAllowed('test', $this->_root));
        foreach ($this->_root->getChildComponents() as $c) {
            $this->assertTrue($this->_acl->isAllowed('test', $c));
        }
        $this->assertTrue($this->_acl->isAllowed('test', $this->_root->getComponentById('4')));
    }

    public function testDynamicComponent2()
    {
        $this->_acl->allowComponent('test', 'Vps_Component_Acl_TestComponent');
        $this->assertFalse($this->_acl->isAllowed('test', $this->_root));
        $this->assertFalse($this->_acl->isAllowed('test', $this->_root->getComponentById('1')));
        $this->assertTrue($this->_acl->isAllowed('test', $this->_root->getComponentById('3')));
        $this->assertTrue($this->_acl->isAllowed('test', $this->_root->getComponentById('4')));
{'fraction_non_alphanumeric': 0.18198577824598366, 'fraction_numerical': 0.00237029233605478, 'mean_word_length': 4.378895184135978, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 225, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1058219', 'n_tokens_mistral': 2293, 'n_tokens_neox': 2355, 'n_words': 238}