/** * @dataProvider providerGetAll * @param $vhost * @param $expectedUrl */ public function testGetAll($vhost, $expectedUrl) { $manager = new PolicyManager(); $manager->setClient($this->client); $this->client->expects($this->once())->method('query')->with(ClientInterface::METHOD_GET, $expectedUrl)->willReturn(json_encode(['policies' => 'test'])); $this->assertEquals(['policies' => 'test'], $manager->getAll($vhost)); }
public function deletePolicies($vhost, $policies) { if ('*' === $policies) { //so you want to destroy all policies, as you whish, let me time to list'em all $policies = $this->policyManager->getAll(urlencode($vhost)); } elseif (!$vhost) { throw new \InvalidArgumentException('If you want to delete certain policie(s) you have to provide vhost'); } else { //few policies to delete, let stack them in array $policies = explode(',', $policies); array_walk($policies, function (&$item, $key, $vhost) { $item = ['vhost' => $vhost, 'name' => trim($item)]; }, $vhost); } if (0 == count($policies)) { $this->logger->error('No policy found.'); return; } foreach ($policies as $policy) { $this->policyManager->delete(urlencode($policy['vhost']), $policy['name']); } }