spec\LdapTools\AttributeConverter\ConvertGPLinkSpec::it_should_aggregate_values_when_converting_an_array_of_GPOLinks_to_ldap_on_modification PHP Метод

    function it_should_aggregate_values_when_converting_an_array_of_GPOLinks_to_ldap_on_modification($connection)
    {
        // This is starting to get really pug fugly...
        $fooBarGPLink = '[LDAP://cn={8E1F85EB-4882-4920-88A5-CF52F31D8D32},cn=policies,cn=system,DC=example,DC=local;0]';
        $fooBarResult = [0 => ['distinguishedname' => ['count' => 1, 0 => "cn={8E1F85EB-4882-4920-88A5-CF52F31D8D32},cn=policies,cn=system,DC=example,DC=local"], 'dn' => "cn={8E1F85EB-4882-4920-88A5-CF52F31D8D32},cn=policies,cn=system,DC=example,DC=local"], 'count' => 1];
        $anotherResult = $this->expectedDNResult;
        $anotherResult = array_reverse($anotherResult);
        $anotherResult[1] = ['distinguishedname' => ['count' => 1, 0 => "cn={8E1F85EB-4882-4920-88A5-CF52F31D8D32},cn=policies,cn=system,DC=example,DC=local"], 'count' => 1, 'dn' => "cn={8E1F85EB-4882-4920-88A5-CF52F31D8D32},cn=policies,cn=system,DC=example,DC=local"];
        // The search for the DN info on 'FooBar'
        $connection->execute(Argument::that(function ($operation) {
            return $operation->getFilter() == '(&(&(objectClass=groupPolicyContainer))(displayName=FooBar))';
        }))->willReturn($fooBarResult);
        // We should add the GPO to the end, which in the case of the string result ends up at the front...
        $this->setOperationType(AttributeConverterInterface::TYPE_MODIFY);
        $this->setBatch(new Batch(Batch::TYPE['ADD'], 'gpoLinks', [new GPOLink('FooBar')]));
        $this->toLdap([new GPOLink('FooBar')])->shouldBeEqualTo($fooBarGPLink . implode('', $this->gPLinks));
        // The search for the DN info on 'Foo'
        $fooResult = $this->expectedDNResult;
        unset($fooResult[1]);
        $fooResult['count'] = 1;
        $connection->execute(Argument::that(function ($operation) {
            return $operation->getFilter() == '(&(&(objectClass=groupPolicyContainer))(displayName=Foo))';
        }))->willReturn($fooResult);
        // This should remove the 'Foo' GPO link...
        $this->setBatch(new Batch(Batch::TYPE['REMOVE'], 'gpoLinks', [new GPOLink('Foo')]));
        $this->toLdap([new GPOLink('Foo')])->shouldBeEqualTo($fooBarGPLink . $this->gPLinks[1]);
        // The search for the DN info on 'Bar'
        $barResult = $this->expectedDNResult;
        $barResult[0] = $barResult[1];
        $barResult['count'] = 1;
        $connection->execute(Argument::that(function ($operation) {
            return $operation->getFilter() == '(&(&(objectClass=groupPolicyContainer))(displayName=Bar))';
        }))->willReturn($barResult);
        // This should replace all GPO links, reversing the order of the last two...
        $this->setBatch(new Batch(Batch::TYPE['REPLACE'], 'gpoLinks', [new GPOLink('Foo'), new GPOLink('Bar', 2), new GPOLink('FooBar')]));
        $this->toLdap([new GPOLink('Foo'), new GPOLink('Bar', 2), new GPOLink('FooBar')])->shouldBeEqualTo($fooBarGPLink . implode('', array_reverse($this->gPLinks)));
    }