Esempio n. 1
0
 public function testGetQuotaUsage()
 {
     $domain = self::randomName();
     $limit = mt_rand(0, 100);
     $offset = mt_rand(0, 100);
     $req = new \Zimbra\Admin\Request\GetQuotaUsage($domain, false, $limit, $offset, QuotaSortBy::PERCENT_USED(), false, true);
     $this->assertInstanceOf('Zimbra\\Admin\\Request\\Base', $req);
     $this->assertSame($domain, $req->getDomain());
     $this->assertFalse($req->getAllServers());
     $this->assertSame($limit, $req->getLimit());
     $this->assertSame($offset, $req->getOffset());
     $this->assertSame('percentUsed', $req->getSortBy()->value());
     $this->assertFalse($req->getSortAscending());
     $this->assertTrue($req->getRefresh());
     $req->setDomain($domain)->setAllServers(true)->setLimit($limit)->setOffset($offset)->setSortBy(QuotaSortBy::TOTAL_USED())->setSortAscending(true)->setRefresh(false);
     $this->assertSame($domain, $req->getDomain());
     $this->assertTrue($req->getAllServers());
     $this->assertSame($limit, $req->getLimit());
     $this->assertSame($offset, $req->getOffset());
     $this->assertSame('totalUsed', $req->getSortBy()->value());
     $this->assertTrue($req->getSortAscending());
     $this->assertFalse($req->getRefresh());
     $xml = '<?xml version="1.0"?>' . "\n" . '<GetQuotaUsageRequest ' . 'domain="' . $domain . '" ' . 'allServers="true" ' . 'limit="' . $limit . '" ' . 'offset="' . $offset . '" ' . 'sortBy="' . QuotaSortBy::TOTAL_USED() . '" ' . 'sortAscending="true" ' . 'refresh="false" />';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = ['GetQuotaUsageRequest' => ['_jsns' => 'urn:zimbraAdmin', 'domain' => $domain, 'allServers' => true, 'limit' => $limit, 'offset' => $offset, 'sortBy' => QuotaSortBy::TOTAL_USED()->value(), 'sortAscending' => true, 'refresh' => false]];
     $this->assertEquals($array, $req->toArray());
 }