Esempio n. 1
0
 public function testAccountSelector()
 {
     $value = $this->faker->word;
     $acc = new AccountSelector(AccountBy::ID(), $value);
     $this->assertTrue($acc->getBy()->is('id'));
     $acc->setBy(AccountBy::ADMIN_NAME());
     $this->assertTrue($acc->getBy()->is('adminName'));
     $xml = '<?xml version="1.0"?>' . "\n" . '<account by="' . AccountBy::ADMIN_NAME() . '">' . $value . '</account>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $acc);
     $array = ['account' => ['by' => AccountBy::ADMIN_NAME()->value(), '_content' => $value]];
     $this->assertEquals($array, $acc->toArray());
 }
Esempio n. 2
0
 public function testTargetSpec()
 {
     $value = $this->faker->word;
     $target = new TargetSpec(TargetType::DL(), AccountBy::ID(), $value);
     $this->assertTrue($target->getTargetType()->is('dl'));
     $this->assertTrue($target->getAccountBy()->is('id'));
     $target->setTargetType(TargetType::ACCOUNT())->setAccountBy(AccountBy::NAME());
     $this->assertTrue($target->getTargetType()->is('account'));
     $this->assertTrue($target->getAccountBy()->is('name'));
     $xml = '<?xml version="1.0"?>' . "\n" . '<target type="' . TargetType::ACCOUNT() . '" by="' . AccountBy::NAME() . '">' . $value . '</target>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $target);
     $array = array('target' => array('type' => TargetType::ACCOUNT()->value(), 'by' => AccountBy::NAME()->value(), '_content' => $value));
     $this->assertEquals($array, $target->toArray());
 }