spec\LdapTools\Object\LdapObjectManagerSpec::it_should_restore_a_ldap_object_using_restore PHP Метод

it_should_restore_a_ldap_object_using_restore() публичный Метод

    function it_should_restore_a_ldap_object_using_restore($connection)
    {
        $dn = 'cn=foo\\0ADEL:0101011,cn=Deleted Objects,dc=example,dc=local';
        $ldapObject1 = new LdapObject(['dn' => $dn, 'lastKnownLocation' => 'cn=Users,dc=example,dc=local'], 'deleted');
        $ldapObject2 = new LdapObject(['dn' => $dn, 'lastKnownLocation' => 'cn=Users,dc=example,dc=local'], 'deleted');
        $connection->execute(Argument::that(function ($operation) use($dn) {
            /** @var BatchModifyOperation $operation */
            $batches = $operation->getBatchCollection()->toArray();
            return $batches[0]->isTypeRemoveAll() && $batches[0]->getAttribute() == 'isDeleted' && $batches[1]->isTypeReplace() && $batches[1]->getAttribute() == 'distinguishedName' && $batches[1]->getValues() == ['cn=foo,cn=Users,dc=example,dc=local'] && $operation->getDn() == $dn;
        }))->shouldBeCalled();
        $this->restore($ldapObject1);
        $connection->execute(Argument::that(function ($operation) use($dn) {
            /** @var BatchModifyOperation $operation */
            $batches = $operation->getBatchCollection()->toArray();
            return $batches[0]->isTypeRemoveAll() && $batches[0]->getAttribute() == 'isDeleted' && $batches[1]->isTypeReplace() && $batches[1]->getAttribute() == 'distinguishedName' && $batches[1]->getValues() == ['cn=foo,ou=Employees,dc=example,dc=local'] && $operation->getDn() == $dn;
        }))->shouldBeCalled();
        $this->restore($ldapObject2, 'ou=Employees,dc=example,dc=local');
    }