Пример #1
0
 /**
  * Test URN construction from string.
  *
  * @dataProvider provideUrnStrings()
  *
  * @param string $input
  * @param string $output
  * @param array  $expectations
  */
 public function testUrnConstructionFromString($input, $output, array $expectations)
 {
     $urn = Urn::fromString($input);
     $this->assertSame($output, (string) $urn);
     $this->assertSame($expectations['nid'], $urn->getNamespaceIdentifier());
     $this->assertSame($expectations['nss'], $urn->getNamespaceSpecificString());
 }
Пример #2
0
 /**
  * Create notification type from string
  *
  * @param string $string
  *
  * @throws InvalidArgumentException
  * @return $this
  */
 public static function fromString($string = self::DEFAULT_NOTIFICATION_TYPE)
 {
     $tuple = explode(':', $string, 2);
     $token = array_shift($tuple);
     if (self::UUID_TOKEN === strtolower($token)) {
         return self::fromUuid(Uuid::fromString($string));
     }
     if (self::URN_TOKEN === strtolower($token)) {
         return self::fromUrn(Urn::fromString($string));
     }
     $notificationType = new static();
     $notificationType->setToken($token);
     $notificationType->setValue(array_pop($tuple));
     return $notificationType;
 }
Пример #3
0
 /**
  * @covers GravityMedia\Urn\Urn::equals()
  */
 public function testEqualityOperator()
 {
     $urn = Urn::fromString('urn:this-is-an-example:t(h)i+s,i-s.a:n=o@t;h$e_r!e*x\'a%m/p?l#e');
     $this->assertTrue($urn->equals($urn));
 }