public function testAddAccountLoggerApi()
 {
     $category = $this->faker->word;
     $value = $this->faker->word;
     $logger = new LoggerInfo($category, LoggingLevel::ERROR());
     $account = new AccountSelector(AccountBy::NAME(), $value);
     $this->api->addAccountLogger($logger, $account);
     $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:AddAccountLoggerRequest>' . '<urn1:logger category="' . $category . '" level="' . LoggingLevel::ERROR() . '" />' . '<urn1:account by="' . AccountBy::NAME() . '">' . $value . '</urn1:account>' . '</urn1:AddAccountLoggerRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Example #2
0
 public function testLoggerInfo()
 {
     $value = $this->faker->word;
     $logger = new LoggerInfo($value, LoggingLevel::ERROR());
     $this->assertSame($value, $logger->getCategory());
     $this->assertSame('error', $logger->getLevel()->value());
     $logger->setCategory($value)->setLevel(LoggingLevel::INFO());
     $this->assertSame($value, $logger->getCategory());
     $this->assertSame('info', $logger->getLevel()->value());
     $xml = '<?xml version="1.0"?>' . "\n" . '<logger category="' . $value . '" level="' . LoggingLevel::INFO() . '" />';
     $this->assertXmlStringEqualsXmlString($xml, (string) $logger);
     $array = ['logger' => ['category' => $value, 'level' => LoggingLevel::INFO()->value()]];
     $this->assertEquals($array, $logger->toArray());
 }
Example #3
0
 public function testLoggingLevel()
 {
     $values = array('error', 'warn', 'info', 'debug', 'trace');
     foreach ($values as $value) {
         $this->assertTrue(\Zimbra\Enum\LoggingLevel::has($value));
     }
 }
Example #4
0
 public function testRemoveAccountLogger()
 {
     $value = self::randomName();
     $category = self::randomName();
     $account = new \Zimbra\Struct\AccountSelector(AccountBy::NAME(), $value);
     $logger = new \Zimbra\Admin\Struct\LoggerInfo($category, LoggingLevel::ERROR());
     $this->_api->removeAccountLogger($account, $logger);
     $client = $this->_api->client();
     $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:RemoveAccountLoggerRequest>' . '<urn1:account by="' . AccountBy::NAME() . '">' . $value . '</urn1:account>' . '<urn1:logger category="' . $category . '" level="' . LoggingLevel::ERROR() . '" />' . '</urn1:RemoveAccountLoggerRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Example #5
0
 public function testRemoveAccountLogger()
 {
     $value = self::randomName();
     $category = self::randomName();
     $account = new \Zimbra\Struct\AccountSelector(AccountBy::NAME(), $value);
     $logger = new \Zimbra\Admin\Struct\LoggerInfo($category, LoggingLevel::ERROR());
     $req = new \Zimbra\Admin\Request\RemoveAccountLogger($account, $logger);
     $this->assertInstanceOf('Zimbra\\Admin\\Request\\Base', $req);
     $this->assertSame($account, $req->getAccount());
     $this->assertSame($logger, $req->getLogger());
     $req->setAccount($account)->setLogger($logger);
     $this->assertSame($account, $req->getAccount());
     $this->assertSame($logger, $req->getLogger());
     $xml = '<?xml version="1.0"?>' . "\n" . '<RemoveAccountLoggerRequest>' . '<account by="' . AccountBy::NAME() . '">' . $value . '</account>' . '<logger category="' . $category . '" level="' . LoggingLevel::ERROR() . '" />' . '</RemoveAccountLoggerRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = ['RemoveAccountLoggerRequest' => ['_jsns' => 'urn:zimbraAdmin', 'account' => ['by' => AccountBy::NAME()->value(), '_content' => $value], 'logger' => ['category' => $category, 'level' => LoggingLevel::ERROR()->value()]]];
     $this->assertEquals($array, $req->toArray());
 }