Example #1
0
 public function testSyncGalAccountApi()
 {
     $id = $this->faker->word;
     $value = $this->faker->word;
     $ds = new SyncGalAccountDataSourceSpec(DataSourceBy::NAME(), $value, false, true);
     $account = new SyncGalAccountSpec($id, [$ds]);
     $this->api->syncGalAccount($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:SyncGalAccountRequest>' . '<urn1:account id="' . $id . '">' . '<urn1:datasource by="' . DataSourceBy::NAME() . '" fullSync="false" reset="true">' . $value . '</urn1:datasource>' . '</urn1:account>' . '</urn1:SyncGalAccountRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
 public function testSyncGalAccountDataSourceSpec()
 {
     $value = $this->faker->word;
     $ds = new SyncGalAccountDataSourceSpec(DataSourceBy::ID(), $value, false, true);
     $this->assertSame('id', $ds->getBy()->value());
     $this->assertSame($value, $ds->getValue());
     $this->assertFalse($ds->getFullSync());
     $this->assertTrue($ds->getReset());
     $ds->setBy(DataSourceBy::NAME())->setFullSync(true)->setReset(false);
     $this->assertSame('name', $ds->getBy()->value());
     $this->assertTrue($ds->getFullSync());
     $this->assertFalse($ds->getReset());
     $xml = '<?xml version="1.0"?>' . "\n" . '<datasource by="' . DataSourceBy::NAME() . '" fullSync="true" reset="false">' . $value . '</datasource>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $ds);
     $array = ['datasource' => ['by' => DataSourceBy::NAME()->value(), 'fullSync' => true, 'reset' => false, '_content' => $value]];
     $this->assertEquals($array, $ds->toArray());
 }
 public function testSyncGalAccountSpec()
 {
     $value1 = $this->faker->word;
     $value2 = $this->faker->word;
     $id = $this->faker->uuid;
     $ds1 = new SyncGalAccountDataSourceSpec(DataSourceBy::ID(), $value1, true, false);
     $ds2 = new SyncGalAccountDataSourceSpec(DataSourceBy::NAME(), $value2, false, true);
     $sync = new SyncGalAccountSpec($id, [$ds1]);
     $this->assertSame($id, $sync->getId());
     $this->assertSame([$ds1], $sync->getDataSources()->all());
     $sync->setId($id)->addDataSource($ds2);
     $this->assertSame($id, $sync->getId());
     $this->assertSame([$ds1, $ds2], $sync->getDataSources()->all());
     $xml = '<?xml version="1.0"?>' . "\n" . '<account id="' . $id . '">' . '<datasource by="' . DataSourceBy::ID() . '" fullSync="true" reset="false">' . $value1 . '</datasource>' . '<datasource by="' . DataSourceBy::NAME() . '" fullSync="false" reset="true">' . $value2 . '</datasource>' . '</account>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $sync);
     $array = ['account' => ['id' => $id, 'datasource' => [['by' => DataSourceBy::ID()->value(), 'fullSync' => true, 'reset' => false, '_content' => $value1], ['by' => DataSourceBy::NAME()->value(), 'fullSync' => false, 'reset' => true, '_content' => $value2]]]];
     $this->assertEquals($array, $sync->toArray());
 }
Example #4
0
 public function testDataSourceBy()
 {
     $values = array('id', 'name');
     foreach ($values as $value) {
         $this->assertTrue(\Zimbra\Enum\DataSourceBy::has($value));
     }
 }
Example #5
0
 public function testSyncGalAccount()
 {
     $id = self::randomName();
     $value = self::randomName();
     $ds = new \Zimbra\Admin\Struct\SyncGalAccountDataSourceSpec(DataSourceBy::NAME(), $value, false, true);
     $account = new \Zimbra\Admin\Struct\SyncGalAccountSpec($id, [$ds]);
     $req = new \Zimbra\Admin\Request\SyncGalAccount($account);
     $this->assertInstanceOf('Zimbra\\Admin\\Request\\Base', $req);
     $this->assertSame($account, $req->getAccount());
     $req->setAccount($account);
     $this->assertSame($account, $req->getAccount());
     $xml = '<?xml version="1.0"?>' . "\n" . '<SyncGalAccountRequest>' . '<account id="' . $id . '">' . '<datasource by="' . DataSourceBy::NAME() . '" fullSync="false" reset="true">' . $value . '</datasource>' . '</account>' . '</SyncGalAccountRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = ['SyncGalAccountRequest' => ['_jsns' => 'urn:zimbraAdmin', 'account' => ['id' => $id, 'datasource' => [['by' => DataSourceBy::NAME()->value(), 'fullSync' => false, 'reset' => true, '_content' => $value]]]]];
     $this->assertEquals($array, $req->toArray());
 }