public function testSetCurrentVolumeApi() { $id = mt_rand(0, 100); $this->api->setCurrentVolume($id, VolumeType::SECONDARY()); $client = $this->api->getClient(); $req = $client->lastRequest(); $xml = '<?xml version="1.0"?>' . "\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraAdmin">' . '<env:Body>' . '<urn1:SetCurrentVolumeRequest ' . 'id="' . $id . '" ' . 'type="' . VolumeType::SECONDARY() . '" ' . '/>' . '</env:Body>' . '</env:Envelope>'; $this->assertXmlStringEqualsXmlString($xml, (string) $req); }
public function testCreateVolumeApi() { $id = mt_rand(0, 10); $type = $this->faker->randomElement(VolumeType::enums()); $threshold = mt_rand(0, 10); $mgbits = mt_rand(0, 10); $mbits = mt_rand(0, 10); $fgbits = mt_rand(0, 10); $fbits = mt_rand(0, 10); $name = $this->faker->word; $rootpath = $this->faker->word; $volume = new VolumeInfo($id, $type, $threshold, $mgbits, $mbits, $fgbits, $fbits, $name, $rootpath, false, true); $this->api->createVolume($volume); $client = $this->api->getClient(); $req = $client->lastRequest(); $xml = '<?xml version="1.0"?>' . "\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraAdmin">' . '<env:Body>' . '<urn1:CreateVolumeRequest>' . '<urn1:volume ' . 'id="' . $id . '" ' . 'type="' . $type . '" ' . 'compressionThreshold="' . $threshold . '" ' . 'mgbits="' . $mgbits . '" ' . 'mbits="' . $mbits . '" ' . 'fgbits="' . $fgbits . '" ' . 'fbits="' . $fbits . '" ' . 'name="' . $name . '" ' . 'rootpath="' . $rootpath . '" ' . 'compressBlobs="false" ' . 'isCurrent="true" />' . '</urn1:CreateVolumeRequest>' . '</env:Body>' . '</env:Envelope>'; $this->assertXmlStringEqualsXmlString($xml, (string) $req); }
public function testVolumeInfo() { $id = mt_rand(0, 10); $type = $this->faker->randomElement(VolumeType::enums()); $threshold = mt_rand(0, 10); $mgbits = mt_rand(0, 10); $mbits = mt_rand(0, 10); $fgbits = mt_rand(0, 10); $fbits = mt_rand(0, 10); $name = $this->faker->word; $rootpath = $this->faker->word; $volume = new VolumeInfo($id, $type, $threshold, $mgbits, $mbits, $fgbits, $fbits, $name, $rootpath, false, true); $this->assertSame($id, $volume->getId()); $this->assertSame($type, $volume->getType()); $this->assertSame($threshold, $volume->getCompressionThreshold()); $this->assertSame($mgbits, $volume->getMgbits()); $this->assertSame($mbits, $volume->getMbits()); $this->assertSame($fgbits, $volume->getFgbits()); $this->assertSame($fbits, $volume->getFbits()); $this->assertSame($name, $volume->getName()); $this->assertSame($rootpath, $volume->getRootPath()); $this->assertFalse($volume->getCompressBlobs()); $this->assertTrue($volume->isCurrent()); $volume->setId($id)->setType($type)->setCompressionThreshold($threshold)->setMgbits($mgbits)->setMbits($mbits)->setFgbits($fgbits)->setFbits($fbits)->setName($name)->setRootPath($rootpath)->setCompressBlobs(true)->setCurrent(false); $this->assertSame($id, $volume->getId()); $this->assertSame($type, $volume->getType()); $this->assertSame($threshold, $volume->getCompressionThreshold()); $this->assertSame($mgbits, $volume->getMgbits()); $this->assertSame($mbits, $volume->getMbits()); $this->assertSame($fgbits, $volume->getFgbits()); $this->assertSame($fbits, $volume->getFbits()); $this->assertSame($name, $volume->getName()); $this->assertSame($rootpath, $volume->getRootPath()); $this->assertTrue($volume->getCompressBlobs()); $this->assertFalse($volume->isCurrent()); $xml = '<?xml version="1.0"?>' . "\n" . '<volume ' . 'id="' . $id . '" ' . 'type="' . $type . '" ' . 'compressionThreshold="' . $threshold . '" ' . 'mgbits="' . $mgbits . '" ' . 'mbits="' . $mbits . '" ' . 'fgbits="' . $fgbits . '" ' . 'fbits="' . $fbits . '" ' . 'name="' . $name . '" ' . 'rootpath="' . $rootpath . '" ' . 'compressBlobs="true" ' . 'isCurrent="false" />'; $this->assertXmlStringEqualsXmlString($xml, (string) $volume); $array = ['volume' => ['id' => $id, 'type' => $type, 'compressionThreshold' => $threshold, 'mgbits' => $mgbits, 'mbits' => $mbits, 'fgbits' => $fgbits, 'fbits' => $fbits, 'name' => $name, 'rootpath' => $rootpath, 'compressBlobs' => true, 'isCurrent' => false]]; $this->assertEquals($array, $volume->toArray()); }
public function testVolumeType() { $values = array(1, 2, 10); foreach ($values as $value) { $this->assertTrue(\Zimbra\Enum\VolumeType::has($value)); } }
public function testSetCurrentVolume() { $id = mt_rand(0, 100); $req = new \Zimbra\Admin\Request\SetCurrentVolume($id, VolumeType::PRIMARY()); $this->assertInstanceOf('Zimbra\\Admin\\Request\\Base', $req); $this->assertEquals($id, $req->getId()); $this->assertEquals(1, $req->getType()->value()); $req->setId($id)->setType(VolumeType::SECONDARY()); $this->assertEquals($id, $req->getId()); $this->assertEquals(2, $req->getType()->value()); $xml = '<?xml version="1.0"?>' . "\n" . '<SetCurrentVolumeRequest ' . 'id="' . $id . '" ' . 'type="' . VolumeType::SECONDARY() . '" ' . '/>'; $this->assertXmlStringEqualsXmlString($xml, (string) $req); $array = ['SetCurrentVolumeRequest' => ['_jsns' => 'urn:zimbraAdmin', 'id' => $id, 'type' => VolumeType::SECONDARY()->value()]]; $this->assertEquals($array, $req->toArray()); }
/** * Sets the type * * @param int $type * @return self */ public function setType($type) { $type = in_array((int) $type, VolumeType::enums()) ? (int) $type : 1; return $this->setProperty('type', $type); }