mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-27 17:56:36 +03:00
Merge branch 'uuid-console-application'
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/**
|
||||
* This file is part of the Rhumsaa\Uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) 2013 Ben Ramsey <http://benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
echo 'Warning: uuid should be invoked via the CLI version of PHP, not the ' . PHP_SAPI . ' SAPI' . PHP_EOL;
|
||||
}
|
||||
|
||||
if (!file_exists(__DIR__ . '/../vendor/autoload.php')) {
|
||||
echo 'You must set up the project dependencies, run the following commands:' . PHP_EOL .
|
||||
'curl -sS https://getcomposer.org/installer | php' . PHP_EOL .
|
||||
'php composer.phar install' . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use Rhumsaa\Uuid\Console\Application;
|
||||
use Rhumsaa\Uuid\Console\Command;
|
||||
|
||||
$app = new Application();
|
||||
$app->add(new Command\GenerateCommand());
|
||||
$app->add(new Command\DecodeCommand());
|
||||
$app->run();
|
||||
+5
-3
@@ -20,13 +20,15 @@
|
||||
"source": "https://github.com/ramsey/uuid"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
"php": ">=5.3.3",
|
||||
"moontoast/math": "~1.1",
|
||||
"symfony/console": "~2.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/dbal": ">=2.3",
|
||||
"moontoast/math": "1.1.0",
|
||||
"phpunit/phpunit": "~3.7"
|
||||
},
|
||||
"bin": ["bin/uuid"],
|
||||
"suggest": {
|
||||
"doctrine/dbal": "Allow the use of a UUID as doctrine field type.",
|
||||
"moontoast/math": "Provides support for large integers."
|
||||
@@ -36,7 +38,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.5.x-dev"
|
||||
"dev-master": "2.6.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of the Rhumsaa\Uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) 2013 Ben Ramsey <http://benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
namespace Rhumsaa\Uuid\Console;
|
||||
|
||||
use Rhumsaa\Uuid\Console\Util;
|
||||
use Rhumsaa\Uuid\Uuid;
|
||||
use Symfony\Component\Console\Application as BaseApplication;
|
||||
|
||||
/**
|
||||
* The console application that handles CLI commands
|
||||
*/
|
||||
class Application extends BaseApplication
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
Util\ErrorHandler::register();
|
||||
parent::__construct('uuid', Uuid::VERSION);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of the Rhumsaa\Uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) 2013 Ben Ramsey <http://benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
namespace Rhumsaa\Uuid\Console\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Helper\TableHelper;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Rhumsaa\Uuid\Console\Exception;
|
||||
use Rhumsaa\Uuid\Uuid;
|
||||
|
||||
/**
|
||||
* Provides the console command to decode UUIDs and dump information about them
|
||||
*/
|
||||
class DecodeCommand extends Command
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
|
||||
$this->setName('decode')
|
||||
->setDescription('Decode a UUID and dump information about it')
|
||||
->addArgument(
|
||||
'uuid',
|
||||
InputArgument::REQUIRED,
|
||||
'The UUID to decode.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if (!Uuid::isValid($input->getArgument('uuid'))) {
|
||||
throw new Exception('Invalid UUID (' . $input->getArgument('uuid') . ')');
|
||||
}
|
||||
|
||||
$uuid = Uuid::fromString($input->getArgument('uuid'));
|
||||
|
||||
$table = $this->getHelperSet()->get('table');
|
||||
$table->setLayout(TableHelper::LAYOUT_COMPACT);
|
||||
|
||||
$table->addRows(array(
|
||||
array('encode:', 'STR:', (string) $uuid),
|
||||
array('', 'INT:', (string) $uuid->getInteger()),
|
||||
));
|
||||
|
||||
if ($uuid->getVariant() != Uuid::RFC_4122) {
|
||||
|
||||
$table->addRows(array(
|
||||
array('decode:', 'variant:', 'Not an RFC 4122 UUID'),
|
||||
));
|
||||
|
||||
$table->render($output);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch ($uuid->getVersion()) {
|
||||
case 1:
|
||||
$version = '1 (time and node based)';
|
||||
break;
|
||||
case 2:
|
||||
$version = '2 (DCE security based)';
|
||||
break;
|
||||
case 3:
|
||||
$version = '3 (name based, MD5)';
|
||||
break;
|
||||
case 4:
|
||||
$version = '4 (random data based)';
|
||||
break;
|
||||
case 5:
|
||||
$version = '5 (name based, SHA-1)';
|
||||
break;
|
||||
}
|
||||
|
||||
$table->addRows(array(
|
||||
array('decode:', 'variant:', 'RFC 4122'),
|
||||
array('', 'version:', $version),
|
||||
));
|
||||
|
||||
if ($uuid->getVersion() == 1) {
|
||||
$table->addRows(array(
|
||||
array('', 'content:', 'time: ' . $uuid->getDateTime()->format('c')),
|
||||
array('', '', 'clock: ' . $uuid->getClockSequence() . ' (usually random)'),
|
||||
array('', '', 'node: ' . substr(chunk_split($uuid->getNodeHex(), 2, ':'), 0, -1)),
|
||||
));
|
||||
}
|
||||
|
||||
if ($uuid->getVersion() == 4) {
|
||||
$table->addRows(array(
|
||||
array('', 'content:', substr(chunk_split($uuid->getHex(), 2, ':'), 0, -1)),
|
||||
array('', '', '(no semantics: random data only)'),
|
||||
));
|
||||
}
|
||||
|
||||
if ($uuid->getVersion() == 3 || $uuid->getVersion() == 5) {
|
||||
$table->addRows(array(
|
||||
array('', 'content:', substr(chunk_split($uuid->getHex(), 2, ':'), 0, -1)),
|
||||
array('', '', '(not decipherable: MD5 message digest only)'),
|
||||
));
|
||||
}
|
||||
|
||||
$table->render($output);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of the Rhumsaa\Uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) 2013 Ben Ramsey <http://benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
namespace Rhumsaa\Uuid\Console\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Rhumsaa\Uuid\Console\Exception;
|
||||
use Rhumsaa\Uuid\Uuid;
|
||||
|
||||
/**
|
||||
* Provides the console command to generate UUIDs
|
||||
*/
|
||||
class GenerateCommand extends Command
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
|
||||
$this->setName('generate')
|
||||
->setDescription('Generate a UUID')
|
||||
->addArgument(
|
||||
'version',
|
||||
InputArgument::OPTIONAL,
|
||||
'The UUID version to generate. Supported are version "1", "3", '
|
||||
. '"4" and "5".',
|
||||
1
|
||||
)
|
||||
->addArgument(
|
||||
'namespace',
|
||||
InputArgument::OPTIONAL,
|
||||
'For version 3 or 5 UUIDs, the namespace to create a UUID for. '
|
||||
. 'May be either a UUID in string representation or an identifier '
|
||||
. 'for internally pre-defined namespace UUIDs (currently known '
|
||||
. 'are "ns:DNS", "ns:URL", "ns:OID", and "ns:X500").'
|
||||
)
|
||||
->addArgument(
|
||||
'name',
|
||||
InputArgument::OPTIONAL,
|
||||
'For version 3 or 5 UUIDs, the name to create a UUID for. '
|
||||
. 'The name is a string of arbitrary length.'
|
||||
)
|
||||
->addOption(
|
||||
'count',
|
||||
'c',
|
||||
InputOption::VALUE_REQUIRED,
|
||||
'Generate count UUIDs instead of just a single one.',
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$uuids = array();
|
||||
|
||||
$count = filter_var(
|
||||
$input->getOption('count'),
|
||||
FILTER_VALIDATE_INT,
|
||||
array(
|
||||
'default' => 1,
|
||||
'min_range' => 1,
|
||||
)
|
||||
);
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$uuids[] = $this->createUuid(
|
||||
$input->getArgument('version'),
|
||||
$input->getArgument('namespace'),
|
||||
$input->getArgument('name')
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($uuids as $uuid) {
|
||||
$output->writeln((string) $uuid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the requested UUID
|
||||
*
|
||||
* @param int $version
|
||||
* @param string $namespace
|
||||
* @param string $name
|
||||
* @return Uuid
|
||||
*/
|
||||
protected function createUuid($version, $namespace = null, $name = null)
|
||||
{
|
||||
switch ((int) $version) {
|
||||
case 1:
|
||||
$uuid = Uuid::uuid1();
|
||||
break;
|
||||
case 4:
|
||||
$uuid = Uuid::uuid4();
|
||||
break;
|
||||
case 3:
|
||||
case 5:
|
||||
$ns = $this->validateNamespace($namespace);
|
||||
if (empty($name)) {
|
||||
throw new Exception('The name argument is required for version 3 or 5 UUIDs');
|
||||
}
|
||||
if ($version == 3) {
|
||||
$uuid = Uuid::uuid3($ns, $name);
|
||||
} else {
|
||||
$uuid = Uuid::uuid5($ns, $name);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Exception('Invalid UUID version. Supported are version "1", "3", "4", and "5".');
|
||||
}
|
||||
|
||||
return $uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the namespace argument
|
||||
*
|
||||
* @param string $namespace
|
||||
* @return string The namespace, if valid
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function validateNamespace($namespace)
|
||||
{
|
||||
switch ($namespace) {
|
||||
case 'ns:DNS':
|
||||
return Uuid::NAMESPACE_DNS;
|
||||
break;
|
||||
case 'ns:URL':
|
||||
return Uuid::NAMESPACE_URL;
|
||||
break;
|
||||
case 'ns:OID':
|
||||
return Uuid::NAMESPACE_OID;
|
||||
break;
|
||||
case 'ns:X500':
|
||||
return Uuid::NAMESPACE_X500;
|
||||
break;
|
||||
}
|
||||
|
||||
if (Uuid::isValid($namespace)) {
|
||||
return $namespace;
|
||||
}
|
||||
|
||||
throw new Exception('Invalid namespace. '
|
||||
. 'May be either a UUID in string representation or an identifier '
|
||||
. 'for internally pre-defined namespace UUIDs (currently known '
|
||||
. 'are "ns:DNS", "ns:URL", "ns:OID", and "ns:X500").');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of the Rhumsaa\Uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) 2013 Ben Ramsey <http://benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
namespace Rhumsaa\Uuid\Console;
|
||||
|
||||
/**
|
||||
* Console exception
|
||||
*/
|
||||
class Exception extends \RuntimeException
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of the Rhumsaa\Uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) 2013 Ben Ramsey <http://benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
namespace Rhumsaa\Uuid\Console\Util;
|
||||
|
||||
/**
|
||||
* Convert PHP errors into exceptions
|
||||
*/
|
||||
class ErrorHandler
|
||||
{
|
||||
/**
|
||||
* Error handler
|
||||
*
|
||||
* @param int $level Level of the error raised
|
||||
* @param string $message Error message
|
||||
* @param string $file Filename that the error was raised in
|
||||
* @param int $line Line number the error was raised at
|
||||
*
|
||||
* @static
|
||||
* @throws \ErrorException
|
||||
*/
|
||||
public static function handle($level, $message, $file, $line)
|
||||
{
|
||||
// respect error_reporting being disabled
|
||||
if (!error_reporting()) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new \ErrorException($message, 0, $level, $file, $line);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register error handler
|
||||
*
|
||||
* @static
|
||||
*/
|
||||
public static function register()
|
||||
{
|
||||
set_error_handler(array(__CLASS__, 'handle'));
|
||||
}
|
||||
}
|
||||
+70
-14
@@ -85,6 +85,11 @@ final class Uuid
|
||||
*/
|
||||
const RESERVED_FUTURE = 7;
|
||||
|
||||
/**
|
||||
* Version of the Rhumsaa\Uuid package
|
||||
*/
|
||||
const VERSION = '2.6.0-dev';
|
||||
|
||||
/**
|
||||
* For testing, 64-bit system override; if true, treat the system as 32-bit
|
||||
*
|
||||
@@ -226,11 +231,8 @@ final class Uuid
|
||||
{
|
||||
$bytes = '';
|
||||
|
||||
$hex = $this->toString();
|
||||
$hex = str_replace('-', '', $hex);
|
||||
|
||||
foreach (range(-2, -32, 2) as $step) {
|
||||
$bytes = chr(hexdec(substr($hex, $step, 2))) . $bytes;
|
||||
$bytes = chr(hexdec(substr($this->getHex(), $step, 2))) . $bytes;
|
||||
}
|
||||
|
||||
return $bytes;
|
||||
@@ -418,6 +420,42 @@ final class Uuid
|
||||
return $this->fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hexadecimal value of the UUID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHex()
|
||||
{
|
||||
return str_replace('-', '', $this->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the integer value of the UUID, represented as a BigNumber
|
||||
*
|
||||
* @return \Moontoast\Math\BigNumber BigNumber representation of the unsigned 128-bit integer value
|
||||
* @throws Exception\UnsatisfiedDependencyException if Moontoast\Math\BigNumber is not present
|
||||
*/
|
||||
public function getInteger()
|
||||
{
|
||||
if (!self::hasBigNumber()) {
|
||||
throw new Exception\UnsatisfiedDependencyException(
|
||||
'Cannot call ' . __METHOD__ . ' without support for large '
|
||||
. 'integers, since integer is an unsigned '
|
||||
. '128-bit integer; Moontoast\Math\BigNumber is required'
|
||||
. '; consider calling getMostSignificantBitsHex instead'
|
||||
);
|
||||
}
|
||||
|
||||
$number = \Moontoast\Math\BigNumber::baseConvert(
|
||||
$this->getHex(),
|
||||
16,
|
||||
10
|
||||
);
|
||||
|
||||
return new \Moontoast\Math\BigNumber($number);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the least significant 64 bits of this UUID's 128 bit value
|
||||
*
|
||||
@@ -1055,6 +1093,33 @@ final class Uuid
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the network interface configuration for the system
|
||||
*
|
||||
* @todo Needs evaluation and possibly modification to ensure this works
|
||||
* well across multiple platforms.
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
protected static function getIfconfig()
|
||||
{
|
||||
$ifconfig = '';
|
||||
|
||||
switch (strtoupper(substr(php_uname('a'), 0, 3))) {
|
||||
case 'WIN':
|
||||
$ifconfig = `ipconfig /all 2>&1`;
|
||||
break;
|
||||
case 'DAR':
|
||||
$ifconfig = `ifconfig 2>&1`;
|
||||
break;
|
||||
case 'LIN':
|
||||
default:
|
||||
$ifconfig = `netstat -ie 2>&1`;
|
||||
break;
|
||||
}
|
||||
|
||||
return $ifconfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hardware address as a 48-bit positive integer. If all attempts to
|
||||
* obtain the hardware address fail, we choose a random 48-bit number with
|
||||
@@ -1064,25 +1129,16 @@ final class Uuid
|
||||
* returned.
|
||||
*
|
||||
* @return string
|
||||
* @todo Needs evaluation and possibly modification to ensure this works
|
||||
* well across multiple platforms.
|
||||
*/
|
||||
protected static function getNodeFromSystem()
|
||||
{
|
||||
// If we're on Windows, use ipconfig; otherwise use ifconfig
|
||||
if (strtoupper(substr(php_uname('a'), 0, 3)) == 'WIN') {
|
||||
$ifconfig = `ipconfig /all 2>&1`;
|
||||
} else {
|
||||
$ifconfig = `ifconfig 2>&1`;
|
||||
}
|
||||
|
||||
$node = null;
|
||||
$pattern = '/[^:]([0-9A-Fa-f]{2}([:-])[0-9A-Fa-f]{2}(\2[0-9A-Fa-f]{2}){4})[^:]/';
|
||||
$matches = array();
|
||||
|
||||
// Search the ifconfig output for all MAC addresses and return
|
||||
// the first one found
|
||||
if (preg_match_all($pattern, $ifconfig, $matches, PREG_PATTERN_ORDER)) {
|
||||
if (preg_match_all($pattern, self::getIfconfig(), $matches, PREG_PATTERN_ORDER)) {
|
||||
$node = $matches[1][0];
|
||||
$node = str_replace(':', '', $node);
|
||||
$node = str_replace('-', '', $node);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace Rhumsaa\Uuid\Console;
|
||||
|
||||
class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Application::__construct
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$app = new Application();
|
||||
|
||||
// Reset the error handler, since the constructor sets it
|
||||
restore_error_handler();
|
||||
|
||||
$this->assertInstanceOf('Rhumsaa\\Uuid\\Console\\Application', $app);
|
||||
$this->assertEquals('uuid', $app->getName());
|
||||
$this->assertEquals(\Rhumsaa\Uuid\Uuid::VERSION, $app->getVersion());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
namespace Rhumsaa\Uuid\Console\Command;
|
||||
|
||||
use Rhumsaa\Uuid\Console\Util\TestOutput;
|
||||
use Rhumsaa\Uuid\Uuid;
|
||||
use Symfony\Component\Console\Input\StringInput;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
|
||||
class DecodeCommandTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $execute;
|
||||
protected $decode;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->execute = new \ReflectionMethod('Rhumsaa\\Uuid\\Console\\Command\\DecodeCommand', 'execute');
|
||||
$this->execute->setAccessible(true);
|
||||
|
||||
$this->decode = new DecodeCommand();
|
||||
$this->decode->setApplication(new \Rhumsaa\Uuid\Console\Application());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\DecodeCommand::configure
|
||||
*/
|
||||
public function testConfigure()
|
||||
{
|
||||
$decode = new DecodeCommand();
|
||||
|
||||
$this->assertEquals('decode', $decode->getName());
|
||||
$this->assertEquals('Decode a UUID and dump information about it', $decode->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\DecodeCommand::execute
|
||||
* @expectedException Rhumsaa\Uuid\Console\Exception
|
||||
* @expectedExceptionMessage Invalid UUID
|
||||
*/
|
||||
public function testExecuteForInvalidUuid()
|
||||
{
|
||||
$input = new StringInput(
|
||||
'foobar',
|
||||
$this->decode->getDefinition()
|
||||
);
|
||||
|
||||
$output = new BufferedOutput();
|
||||
|
||||
$this->execute->invoke($this->decode, $input, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\DecodeCommand::execute
|
||||
*/
|
||||
public function testExecuteForNonRFC4122Uuid()
|
||||
{
|
||||
$expected = file_get_contents('tests/console-mocks/testExecuteForNonRFC4122Uuid.txt');
|
||||
|
||||
$input = new StringInput(
|
||||
'ff6f8cb0-c57d-11e1-0b21-0800200c9a66',
|
||||
$this->decode->getDefinition()
|
||||
);
|
||||
|
||||
$output = new BufferedOutput();
|
||||
|
||||
$this->execute->invoke($this->decode, $input, $output);
|
||||
|
||||
$this->assertEquals($expected, $output->fetch());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\DecodeCommand::execute
|
||||
*/
|
||||
public function testExecuteForVersion1Uuid()
|
||||
{
|
||||
$expected = file_get_contents('tests/console-mocks/testExecuteForVersion1Uuid.txt');
|
||||
|
||||
$input = new StringInput(
|
||||
'2ddbf60e-7fc4-11e3-a5ac-080027cd5e4d',
|
||||
$this->decode->getDefinition()
|
||||
);
|
||||
|
||||
$output = new BufferedOutput();
|
||||
|
||||
$this->execute->invoke($this->decode, $input, $output);
|
||||
|
||||
$this->assertEquals($expected, $output->fetch());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\DecodeCommand::execute
|
||||
*/
|
||||
public function testExecuteForVersion2Uuid()
|
||||
{
|
||||
$expected = file_get_contents('tests/console-mocks/testExecuteForVersion2Uuid.txt');
|
||||
|
||||
$input = new StringInput(
|
||||
'6fa459ea-ee8a-2ca4-894e-db77e160355e',
|
||||
$this->decode->getDefinition()
|
||||
);
|
||||
|
||||
$output = new BufferedOutput();
|
||||
|
||||
$this->execute->invoke($this->decode, $input, $output);
|
||||
|
||||
$this->assertEquals($expected, $output->fetch());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\DecodeCommand::execute
|
||||
*/
|
||||
public function testExecuteForVersion3Uuid()
|
||||
{
|
||||
$expected = file_get_contents('tests/console-mocks/testExecuteForVersion3Uuid.txt');
|
||||
|
||||
$input = new StringInput(
|
||||
'6fa459ea-ee8a-3ca4-894e-db77e160355e',
|
||||
$this->decode->getDefinition()
|
||||
);
|
||||
|
||||
$output = new BufferedOutput();
|
||||
|
||||
$this->execute->invoke($this->decode, $input, $output);
|
||||
|
||||
$this->assertEquals($expected, $output->fetch());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\DecodeCommand::execute
|
||||
*/
|
||||
public function testExecuteForVersion4Uuid()
|
||||
{
|
||||
$expected = file_get_contents('tests/console-mocks/testExecuteForVersion4Uuid.txt');
|
||||
|
||||
$input = new StringInput(
|
||||
'83fc61b6-b5ef-467f-9a15-89ddee668005',
|
||||
$this->decode->getDefinition()
|
||||
);
|
||||
|
||||
$output = new BufferedOutput();
|
||||
|
||||
$this->execute->invoke($this->decode, $input, $output);
|
||||
|
||||
$this->assertEquals($expected, $output->fetch());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\DecodeCommand::execute
|
||||
*/
|
||||
public function testExecuteForVersion5Uuid()
|
||||
{
|
||||
$expected = file_get_contents('tests/console-mocks/testExecuteForVersion5Uuid.txt');
|
||||
|
||||
$input = new StringInput(
|
||||
'886313e1-3b8a-5372-9b90-0c9aee199e5d',
|
||||
$this->decode->getDefinition()
|
||||
);
|
||||
|
||||
$output = new BufferedOutput();
|
||||
|
||||
$this->execute->invoke($this->decode, $input, $output);
|
||||
|
||||
$this->assertEquals($expected, $output->fetch());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,635 @@
|
||||
<?php
|
||||
namespace Rhumsaa\Uuid\Console\Command;
|
||||
|
||||
use Rhumsaa\Uuid\Console\Util\TestOutput;
|
||||
use Rhumsaa\Uuid\Uuid;
|
||||
use Symfony\Component\Console\Input\StringInput;
|
||||
|
||||
class GenerateCommandTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
const FOO_NS = 'bbd8a651-6f00-11e3-8ad8-28cfe91e4895';
|
||||
|
||||
protected $execute;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->execute = new \ReflectionMethod('Rhumsaa\\Uuid\\Console\\Command\\GenerateCommand', 'execute');
|
||||
$this->execute->setAccessible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::configure
|
||||
*/
|
||||
public function testConfigure()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$this->assertEquals('generate', $generate->getName());
|
||||
$this->assertEquals('Generate a UUID', $generate->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
*/
|
||||
public function testExecuteForUuidDefault()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
|
||||
$this->assertCount(1, $output->messages);
|
||||
$this->assertTrue(Uuid::isValid($output->messages[0]));
|
||||
$this->assertEquals(1, Uuid::fromString($output->messages[0])->getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
*/
|
||||
public function testExecuteForUuidDefaultWithCount()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
//
|
||||
// Test using the "-c" option
|
||||
//
|
||||
|
||||
$input1 = new StringInput(
|
||||
'-c 9',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output1 = new TestOutput();
|
||||
$this->execute->invoke($generate, $input1, $output1);
|
||||
|
||||
$this->assertCount(9, $output1->messages);
|
||||
|
||||
foreach ($output1->messages as $uuid) {
|
||||
$this->assertTrue(Uuid::isValid($uuid));
|
||||
$this->assertEquals(1, Uuid::fromString($uuid)->getVersion());
|
||||
}
|
||||
|
||||
//
|
||||
// Test using the "--count" option
|
||||
//
|
||||
|
||||
$input2 = new StringInput(
|
||||
'--count=12',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output2 = new TestOutput();
|
||||
$this->execute->invoke($generate, $input2, $output2);
|
||||
|
||||
$this->assertCount(12, $output2->messages);
|
||||
|
||||
foreach ($output2->messages as $uuid) {
|
||||
$this->assertTrue(Uuid::isValid($uuid));
|
||||
$this->assertEquals(1, Uuid::fromString($uuid)->getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion1()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'1',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
|
||||
$this->assertCount(1, $output->messages);
|
||||
$this->assertTrue(Uuid::isValid($output->messages[0]));
|
||||
$this->assertEquals(1, Uuid::fromString($output->messages[0])->getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion1WithCount()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
//
|
||||
// Test using the "-c" option
|
||||
//
|
||||
|
||||
$input1 = new StringInput(
|
||||
'1 -c 3',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output1 = new TestOutput();
|
||||
$this->execute->invoke($generate, $input1, $output1);
|
||||
|
||||
$this->assertCount(3, $output1->messages);
|
||||
|
||||
foreach ($output1->messages as $uuid) {
|
||||
$this->assertTrue(Uuid::isValid($uuid));
|
||||
$this->assertEquals(1, Uuid::fromString($uuid)->getVersion());
|
||||
}
|
||||
|
||||
//
|
||||
// Test using the "--count" option
|
||||
//
|
||||
|
||||
$input2 = new StringInput(
|
||||
'1 --count=8',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output2 = new TestOutput();
|
||||
$this->execute->invoke($generate, $input2, $output2);
|
||||
|
||||
$this->assertCount(8, $output2->messages);
|
||||
|
||||
foreach ($output2->messages as $uuid) {
|
||||
$this->assertTrue(Uuid::isValid($uuid));
|
||||
$this->assertEquals(1, Uuid::fromString($uuid)->getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion4()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'4',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
|
||||
$this->assertCount(1, $output->messages);
|
||||
$this->assertTrue(Uuid::isValid($output->messages[0]));
|
||||
$this->assertEquals(4, Uuid::fromString($output->messages[0])->getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion4WithCount()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
//
|
||||
// Test using the "-c" option
|
||||
//
|
||||
|
||||
$input1 = new StringInput(
|
||||
'4 -c 3',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output1 = new TestOutput();
|
||||
$this->execute->invoke($generate, $input1, $output1);
|
||||
|
||||
$this->assertCount(3, $output1->messages);
|
||||
|
||||
foreach ($output1->messages as $uuid) {
|
||||
$this->assertTrue(Uuid::isValid($uuid));
|
||||
$this->assertEquals(4, Uuid::fromString($uuid)->getVersion());
|
||||
}
|
||||
|
||||
//
|
||||
// Test using the "--count" option
|
||||
//
|
||||
|
||||
$input2 = new StringInput(
|
||||
'4 --count=8',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output2 = new TestOutput();
|
||||
$this->execute->invoke($generate, $input2, $output2);
|
||||
|
||||
$this->assertCount(8, $output2->messages);
|
||||
|
||||
foreach ($output2->messages as $uuid) {
|
||||
$this->assertTrue(Uuid::isValid($uuid));
|
||||
$this->assertEquals(4, Uuid::fromString($uuid)->getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::validateNamespace
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion3WithDnsNs()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'3 ns:DNS "python.org"',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
|
||||
$this->assertCount(1, $output->messages);
|
||||
$this->assertTrue(Uuid::isValid($output->messages[0]));
|
||||
$this->assertEquals(3, Uuid::fromString($output->messages[0])->getVersion());
|
||||
$this->assertEquals('6fa459ea-ee8a-3ca4-894e-db77e160355e', $output->messages[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::validateNamespace
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion3WithUrlNs()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'3 ns:URL "http://python.org/"',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
|
||||
$this->assertCount(1, $output->messages);
|
||||
$this->assertTrue(Uuid::isValid($output->messages[0]));
|
||||
$this->assertEquals(3, Uuid::fromString($output->messages[0])->getVersion());
|
||||
$this->assertEquals('9fe8e8c4-aaa8-32a9-a55c-4535a88b748d', $output->messages[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::validateNamespace
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion3WithOidNs()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'3 ns:OID "1.3.6.1"',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
|
||||
$this->assertCount(1, $output->messages);
|
||||
$this->assertTrue(Uuid::isValid($output->messages[0]));
|
||||
$this->assertEquals(3, Uuid::fromString($output->messages[0])->getVersion());
|
||||
$this->assertEquals('dd1a1cef-13d5-368a-ad82-eca71acd4cd1', $output->messages[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::validateNamespace
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion3WithX500Ns()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'3 ns:X500 "c=ca"',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
|
||||
$this->assertCount(1, $output->messages);
|
||||
$this->assertTrue(Uuid::isValid($output->messages[0]));
|
||||
$this->assertEquals(3, Uuid::fromString($output->messages[0])->getVersion());
|
||||
$this->assertEquals('658d3002-db6b-3040-a1d1-8ddd7d189a4d', $output->messages[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::validateNamespace
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion3WithOtherNs()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'3 bbd8a651-6f00-11e3-8ad8-28cfe91e4895 foobar',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
|
||||
$this->assertCount(1, $output->messages);
|
||||
$this->assertTrue(Uuid::isValid($output->messages[0]));
|
||||
$this->assertEquals(3, Uuid::fromString($output->messages[0])->getVersion());
|
||||
$this->assertEquals('0707b2c0-1f0f-3b2b-9a90-371396a90a86', $output->messages[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::validateNamespace
|
||||
* @expectedException Rhumsaa\Uuid\Console\Exception
|
||||
* @expectedExceptionMessage May be either a UUID in string representation or an identifier
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion3WithInvalidNs()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'3 foo foobar',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::validateNamespace
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion3WithCount()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'3 ns:DNS "python.org" -c 21',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
|
||||
$this->assertCount(21, $output->messages);
|
||||
|
||||
foreach ($output->messages as $uuid) {
|
||||
$this->assertTrue(Uuid::isValid($uuid));
|
||||
$this->assertEquals(3, Uuid::fromString($uuid)->getVersion());
|
||||
$this->assertEquals('6fa459ea-ee8a-3ca4-894e-db77e160355e', $uuid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::validateNamespace
|
||||
* @expectedException Rhumsaa\Uuid\Console\Exception
|
||||
* @expectedExceptionMessage The name argument is required for version 3 or 5 UUIDs
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion3WithoutName()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'3 ns:DNS',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::validateNamespace
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion5WithDnsNs()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'5 ns:DNS "python.org"',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
|
||||
$this->assertCount(1, $output->messages);
|
||||
$this->assertTrue(Uuid::isValid($output->messages[0]));
|
||||
$this->assertEquals(5, Uuid::fromString($output->messages[0])->getVersion());
|
||||
$this->assertEquals('886313e1-3b8a-5372-9b90-0c9aee199e5d', $output->messages[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::validateNamespace
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion5WithUrlNs()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'5 ns:URL "http://python.org/"',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
|
||||
$this->assertCount(1, $output->messages);
|
||||
$this->assertTrue(Uuid::isValid($output->messages[0]));
|
||||
$this->assertEquals(5, Uuid::fromString($output->messages[0])->getVersion());
|
||||
$this->assertEquals('4c565f0d-3f5a-5890-b41b-20cf47701c5e', $output->messages[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::validateNamespace
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion5WithOidNs()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'5 ns:OID "1.3.6.1"',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
|
||||
$this->assertCount(1, $output->messages);
|
||||
$this->assertTrue(Uuid::isValid($output->messages[0]));
|
||||
$this->assertEquals(5, Uuid::fromString($output->messages[0])->getVersion());
|
||||
$this->assertEquals('1447fa61-5277-5fef-a9b3-fbc6e44f4af3', $output->messages[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::validateNamespace
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion5WithX500Ns()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'5 ns:X500 "c=ca"',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
|
||||
$this->assertCount(1, $output->messages);
|
||||
$this->assertTrue(Uuid::isValid($output->messages[0]));
|
||||
$this->assertEquals(5, Uuid::fromString($output->messages[0])->getVersion());
|
||||
$this->assertEquals('cc957dd1-a972-5349-98cd-874190002798', $output->messages[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::validateNamespace
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion5WithOtherNs()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'5 bbd8a651-6f00-11e3-8ad8-28cfe91e4895 foobar',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
|
||||
$this->assertCount(1, $output->messages);
|
||||
$this->assertTrue(Uuid::isValid($output->messages[0]));
|
||||
$this->assertEquals(5, Uuid::fromString($output->messages[0])->getVersion());
|
||||
$this->assertEquals('385c280b-1d07-5d6b-932b-ca7a11d2e7e5', $output->messages[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::validateNamespace
|
||||
* @expectedException Rhumsaa\Uuid\Console\Exception
|
||||
* @expectedExceptionMessage May be either a UUID in string representation or an identifier
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion5WithInvalidNs()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'5 foo foobar',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::validateNamespace
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion5WithCount()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'5 ns:DNS "python.org" -c 21',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
|
||||
$this->assertCount(21, $output->messages);
|
||||
|
||||
foreach ($output->messages as $uuid) {
|
||||
$this->assertTrue(Uuid::isValid($uuid));
|
||||
$this->assertEquals(5, Uuid::fromString($uuid)->getVersion());
|
||||
$this->assertEquals('886313e1-3b8a-5372-9b90-0c9aee199e5d', $uuid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::validateNamespace
|
||||
* @expectedException Rhumsaa\Uuid\Console\Exception
|
||||
* @expectedExceptionMessage The name argument is required for version 3 or 5 UUIDs
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyVersion5WithoutName()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'5 ns:DNS',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::execute
|
||||
* @covers Rhumsaa\Uuid\Console\Command\GenerateCommand::createUuid
|
||||
* @expectedException Rhumsaa\Uuid\Console\Exception
|
||||
* @expectedExceptionMessage Invalid UUID version. Supported are version "1", "3", "4", and "5".
|
||||
*/
|
||||
public function testExecuteForUuidSpecifyInvalidVersion()
|
||||
{
|
||||
$generate = new GenerateCommand();
|
||||
|
||||
$input = new StringInput(
|
||||
'6',
|
||||
$generate->getDefinition()
|
||||
);
|
||||
|
||||
$output = new TestOutput();
|
||||
|
||||
$this->execute->invoke($generate, $input, $output);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
namespace Rhumsaa\Uuid\Console\Util;
|
||||
|
||||
class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Util\ErrorHandler::register
|
||||
*/
|
||||
public function testRegister()
|
||||
{
|
||||
$expected = array (
|
||||
'Rhumsaa\\Uuid\Console\\Util\\ErrorHandler',
|
||||
'handle',
|
||||
);
|
||||
|
||||
$originalHandler = set_error_handler(function () {});
|
||||
|
||||
ErrorHandler::register();
|
||||
$testHandler = set_error_handler(function () {});
|
||||
|
||||
// Set handler back to original
|
||||
set_error_handler($originalHandler);
|
||||
|
||||
$this->assertEquals($expected, $testHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Util\ErrorHandler::handle
|
||||
* @expectedException ErrorException
|
||||
* @expectedExceptionMessage Test exception
|
||||
*/
|
||||
public function testHandle()
|
||||
{
|
||||
error_reporting(E_ALL);
|
||||
ErrorHandler::handle(1, 'Test exception', __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Console\Util\ErrorHandler::handle
|
||||
*/
|
||||
public function testHandleNoException()
|
||||
{
|
||||
error_reporting(0);
|
||||
|
||||
$this->assertEmpty(ErrorHandler::handle(1, 'Test exception', __FILE__, __LINE__));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace Rhumsaa\Uuid\Console\Util;
|
||||
|
||||
use Symfony\Component\Console\Output\Output;
|
||||
|
||||
class TestOutput extends Output
|
||||
{
|
||||
public $messages = array();
|
||||
|
||||
protected function doWrite($message, $newline)
|
||||
{
|
||||
$this->messages[] = $message;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
namespace Rhumsaa\Uuid;
|
||||
|
||||
require_once 'functions.php';
|
||||
|
||||
/**
|
||||
* This is a backwards-compatibility test to ensure that Rhumsaa\Uuid
|
||||
* maintains backwards compatibility with tag 1.1.2.
|
||||
@@ -382,26 +380,6 @@ class UuidBcTag1_1_2Test extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('0901e600-0154-1000-9b21-0800200c9a66', sprintf('%s', $uuid));
|
||||
}
|
||||
|
||||
/**
|
||||
* This calls php_uname() in getNodeFromSystem. The first time it is
|
||||
* called, it returns "WIN." Each additional times, it returns the
|
||||
* normal system php_uname().
|
||||
*
|
||||
* See the bottom of this test file to see where we are overriding
|
||||
* php_uname() for the purpose of this test.
|
||||
*
|
||||
* @covers Rhumsaa\Uuid\Uuid::uuid1
|
||||
* @covers Rhumsaa\Uuid\Uuid::getNodeFromSystem
|
||||
*/
|
||||
public function testUuid1CoverageForWindows()
|
||||
{
|
||||
$uuid = Uuid::uuid1();
|
||||
$this->assertInstanceOf('\Rhumsaa\Uuid\Uuid', $uuid);
|
||||
$this->assertInstanceOf('\DateTime', $uuid->getDateTime());
|
||||
$this->assertEquals(2, $uuid->getVariant());
|
||||
$this->assertEquals(1, $uuid->getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Uuid::uuid1
|
||||
* @covers Rhumsaa\Uuid\Uuid::getNodeFromSystem
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
namespace Rhumsaa\Uuid;
|
||||
|
||||
require_once 'functions.php';
|
||||
|
||||
class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
@@ -630,26 +628,6 @@ class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('0901e600-0154-1000-9b21-0800200c9a66', sprintf('%s', $uuid));
|
||||
}
|
||||
|
||||
/**
|
||||
* This calls php_uname() in getNodeFromSystem. The first time it is
|
||||
* called, it returns "WIN." Each additional times, it returns the
|
||||
* normal system php_uname().
|
||||
*
|
||||
* See the bottom of this test file to see where we are overriding
|
||||
* php_uname() for the purpose of this test.
|
||||
*
|
||||
* @covers Rhumsaa\Uuid\Uuid::uuid1
|
||||
* @covers Rhumsaa\Uuid\Uuid::getNodeFromSystem
|
||||
*/
|
||||
public function testUuid1CoverageForWindows()
|
||||
{
|
||||
$uuid = Uuid::uuid1();
|
||||
$this->assertInstanceOf('\Rhumsaa\Uuid\Uuid', $uuid);
|
||||
$this->assertInstanceOf('\DateTime', $uuid->getDateTime());
|
||||
$this->assertEquals(2, $uuid->getVariant());
|
||||
$this->assertEquals(1, $uuid->getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Uuid::uuid1
|
||||
* @covers Rhumsaa\Uuid\Uuid::getNodeFromSystem
|
||||
@@ -1488,6 +1466,8 @@ class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
* @covers Rhumsaa\Uuid\Uuid::toString
|
||||
* @covers Rhumsaa\Uuid\Uuid::getBytes
|
||||
* @covers Rhumsaa\Uuid\Uuid::getFieldsHex
|
||||
* @covers Rhumsaa\Uuid\Uuid::getHex
|
||||
* @covers Rhumsaa\Uuid\Uuid::getInteger
|
||||
* @covers Rhumsaa\Uuid\Uuid::getTimeLowHex
|
||||
* @covers Rhumsaa\Uuid\Uuid::getTimeMidHex
|
||||
* @covers Rhumsaa\Uuid\Uuid::getTimeHiAndVersionHex
|
||||
@@ -1509,6 +1489,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
'curly' => '{00000000-0000-0000-0000-000000000000}',
|
||||
'hex' => '00000000000000000000000000000000',
|
||||
'bytes' => 'AAAAAAAAAAAAAAAAAAAAAA==',
|
||||
'int' => '0',
|
||||
'fields' => array(
|
||||
'time_low' => '0',
|
||||
'time_mid' => '0',
|
||||
@@ -1528,6 +1509,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
'curly' => '{00010203-0405-0607-0809-0a0b0c0d0e0f}',
|
||||
'hex' => '000102030405060708090a0b0c0d0e0f',
|
||||
'bytes' => 'AAECAwQFBgcICQoLDA0ODw==',
|
||||
'int' => '5233100606242806050955395731361295',
|
||||
'fields' => array(
|
||||
'time_low' => '10203',
|
||||
'time_mid' => '405',
|
||||
@@ -1547,6 +1529,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
'curly' => '{02d9e6d5-9467-382e-8f9b-9300a64ac3cd}',
|
||||
'hex' => '02d9e6d59467382e8f9b9300a64ac3cd',
|
||||
'bytes' => 'Atnm1ZRnOC6Pm5MApkrDzQ==',
|
||||
'int' => '3789866285607910888100818383505376205',
|
||||
'fields' => array(
|
||||
'time_low' => '02d9e6d5',
|
||||
'time_mid' => '9467',
|
||||
@@ -1566,6 +1549,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
'curly' => '{12345678-1234-5678-1234-567812345678}',
|
||||
'hex' => '12345678123456781234567812345678',
|
||||
'bytes' => 'EjRWeBI0VngSNFZ4EjRWeA==',
|
||||
'int' => '24197857161011715162171839636988778104',
|
||||
'fields' => array(
|
||||
'time_low' => '12345678',
|
||||
'time_mid' => '1234',
|
||||
@@ -1585,6 +1569,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
'curly' => '{6ba7b810-9dad-11d1-80b4-00c04fd430c8}',
|
||||
'hex' => '6ba7b8109dad11d180b400c04fd430c8',
|
||||
'bytes' => 'a6e4EJ2tEdGAtADAT9QwyA==',
|
||||
'int' => '143098242404177361603877621312831893704',
|
||||
'fields' => array(
|
||||
'time_low' => '6ba7b810',
|
||||
'time_mid' => '9dad',
|
||||
@@ -1604,6 +1589,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
'curly' => '{6ba7b811-9dad-11d1-80b4-00c04fd430c8}',
|
||||
'hex' => '6ba7b8119dad11d180b400c04fd430c8',
|
||||
'bytes' => 'a6e4EZ2tEdGAtADAT9QwyA==',
|
||||
'int' => '143098242483405524118141958906375844040',
|
||||
'fields' => array(
|
||||
'time_low' => '6ba7b811',
|
||||
'time_mid' => '9dad',
|
||||
@@ -1623,6 +1609,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
'curly' => '{6ba7b812-9dad-11d1-80b4-00c04fd430c8}',
|
||||
'hex' => '6ba7b8129dad11d180b400c04fd430c8',
|
||||
'bytes' => 'a6e4Ep2tEdGAtADAT9QwyA==',
|
||||
'int' => '143098242562633686632406296499919794376',
|
||||
'fields' => array(
|
||||
'time_low' => '6ba7b812',
|
||||
'time_mid' => '9dad',
|
||||
@@ -1642,6 +1629,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
'curly' => '{6ba7b814-9dad-11d1-80b4-00c04fd430c8}',
|
||||
'hex' => '6ba7b8149dad11d180b400c04fd430c8',
|
||||
'bytes' => 'a6e4FJ2tEdGAtADAT9QwyA==',
|
||||
'int' => '143098242721090011660934971687007695048',
|
||||
'fields' => array(
|
||||
'time_low' => '6ba7b814',
|
||||
'time_mid' => '9dad',
|
||||
@@ -1661,6 +1649,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
'curly' => '{7d444840-9dc0-11d1-b245-5ffdce74fad2}',
|
||||
'hex' => '7d4448409dc011d1b2455ffdce74fad2',
|
||||
'bytes' => 'fURIQJ3AEdGyRV/9znT60g==',
|
||||
'int' => '166508041112410060672666770310773930706',
|
||||
'fields' => array(
|
||||
'time_low' => '7d444840',
|
||||
'time_mid' => '9dc0',
|
||||
@@ -1680,6 +1669,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
'curly' => '{e902893a-9d22-3c7e-a7b8-d6e313b71d9f}',
|
||||
'hex' => 'e902893a9d223c7ea7b8d6e313b71d9f',
|
||||
'bytes' => '6QKJOp0iPH6nuNbjE7cdnw==',
|
||||
'int' => '309723290945582129846206211755626405279',
|
||||
'fields' => array(
|
||||
'time_low' => 'e902893a',
|
||||
'time_mid' => '9d22',
|
||||
@@ -1699,6 +1689,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
'curly' => '{eb424026-6f54-4ef8-a4d0-bb658a1fc6cf}',
|
||||
'hex' => 'eb4240266f544ef8a4d0bb658a1fc6cf',
|
||||
'bytes' => '60JAJm9UTvik0Ltlih/Gzw==',
|
||||
'int' => '312712571721458096795100956955942831823',
|
||||
'fields' => array(
|
||||
'time_low' => 'eb424026',
|
||||
'time_mid' => '6f54',
|
||||
@@ -1718,6 +1709,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
'curly' => '{f81d4fae-7dec-11d0-a765-00a0c91e6bf6}',
|
||||
'hex' => 'f81d4fae7dec11d0a76500a0c91e6bf6',
|
||||
'bytes' => '+B1Prn3sEdCnZQCgyR5r9g==',
|
||||
'int' => '329800735698586629295641978511506172918',
|
||||
'fields' => array(
|
||||
'time_low' => 'f81d4fae',
|
||||
'time_mid' => '7dec',
|
||||
@@ -1737,6 +1729,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
'curly' => '{fffefdfc-fffe-fffe-fffe-fffefdfcfbfa}',
|
||||
'hex' => 'fffefdfcfffefffefffefffefdfcfbfa',
|
||||
'bytes' => '//79/P/+//7//v/+/fz7+g==',
|
||||
'int' => '340277133821575024845345576078114880506',
|
||||
'fields' => array(
|
||||
'time_low' => 'fffefdfc',
|
||||
'time_mid' => 'fffe',
|
||||
@@ -1756,6 +1749,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
'curly' => '{ffffffff-ffff-ffff-ffff-ffffffffffff}',
|
||||
'hex' => 'ffffffffffffffffffffffffffffffff',
|
||||
'bytes' => '/////////////////////w==',
|
||||
'int' => '340282366920938463463374607431768211455',
|
||||
'fields' => array(
|
||||
'time_low' => 'ffffffff',
|
||||
'time_mid' => 'ffff',
|
||||
@@ -1782,7 +1776,9 @@ class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
foreach ($uuids as $uuid) {
|
||||
$this->assertEquals($test['string'], (string) $uuid);
|
||||
$this->assertEquals($test['hex'], $uuid->getHex());
|
||||
$this->assertEquals(base64_decode($test['bytes']), $uuid->getBytes());
|
||||
$this->assertEquals($test['int'], (string) $uuid->getInteger());
|
||||
$this->assertEquals($test['fields'], $uuid->getFieldsHex());
|
||||
$this->assertEquals($test['fields']['time_low'], $uuid->getTimeLowHex());
|
||||
$this->assertEquals($test['fields']['time_mid'], $uuid->getTimeMidHex());
|
||||
@@ -1800,4 +1796,17 @@ class UuidTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Rhumsaa\Uuid\Uuid::getInteger
|
||||
* @expectedException Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException
|
||||
* @expectedExceptionMessage Cannot call Rhumsaa\Uuid\Uuid::getInteger without support for large integers
|
||||
*/
|
||||
public function testGetInteger()
|
||||
{
|
||||
Uuid::$forceNoBigNumber = true;
|
||||
|
||||
$uuid = Uuid::uuid1();
|
||||
$uuid->getInteger();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Rhumsaa\Uuid;
|
||||
|
||||
/**
|
||||
* Overriding the default php_uname() for the purpose of this test so we can
|
||||
* have full code coverage on all the lines.
|
||||
*
|
||||
* This should ensure that we have full code coverage whether the tests are run
|
||||
* on Windows or a *NIX environment. This does not mean that the code has been
|
||||
* tested for both environments if it is only tested in one environment, so
|
||||
* the tests must still be run in both environments to ensure they pass.
|
||||
*/
|
||||
function php_uname($v)
|
||||
{
|
||||
static $run = 0;
|
||||
|
||||
if ($run == 0 && strtoupper(substr(\php_uname('a'), 0, 3)) != 'WIN') {
|
||||
// If this is the first run and the SUT is not Windows, return "Windows"
|
||||
$ret = 'Windows';
|
||||
} elseif ($run == 0 && strtoupper(substr(\php_uname('a'), 0, 3)) == 'WIN') {
|
||||
// If this is the first run and the SUT is Windows, return "Darwin"
|
||||
$ret = 'Darwin';
|
||||
} else {
|
||||
// If this isn't the first run, then use the system php_uname()
|
||||
$ret = \php_uname($v);
|
||||
}
|
||||
|
||||
$run++;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
@@ -12,3 +12,4 @@ if (!file_exists(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'composer.lock')) {
|
||||
$loader = include realpath(dirname(__FILE__) . '/../vendor/autoload.php');
|
||||
|
||||
$loader->add("Doctrine\Tests\DBAL", __DIR__."/../vendor/doctrine/dbal/tests");
|
||||
$loader->add('Rhumsaa\Uuid', __DIR__);
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
encode: STR: ff6f8cb0-c57d-11e1-0b21-0800200c9a66
|
||||
INT: 339532337419071774295426818102463863398
|
||||
decode: variant: Not an RFC 4122 UUID
|
||||
@@ -0,0 +1,7 @@
|
||||
encode: STR: 2ddbf60e-7fc4-11e3-a5ac-080027cd5e4d
|
||||
INT: 60957363443838745229478843813485960781
|
||||
decode: variant: RFC 4122
|
||||
version: 1 (time and node based)
|
||||
content: time: 2014-01-17T22:10:31+00:00
|
||||
clock: 9644 (usually random)
|
||||
node: 08:00:27:cd:5e:4d
|
||||
@@ -0,0 +1,4 @@
|
||||
encode: STR: 6fa459ea-ee8a-2ca4-894e-db77e160355e
|
||||
INT: 148397667964594601879796619558430717278
|
||||
decode: variant: RFC 4122
|
||||
version: 2 (DCE security based)
|
||||
@@ -0,0 +1,6 @@
|
||||
encode: STR: 6fa459ea-ee8a-3ca4-894e-db77e160355e
|
||||
INT: 148397667964594677437660345472754136414
|
||||
decode: variant: RFC 4122
|
||||
version: 3 (name based, MD5)
|
||||
content: 6f:a4:59:ea:ee:8a:3c:a4:89:4e:db:77:e1:60:35:5e
|
||||
(not decipherable: MD5 message digest only)
|
||||
@@ -0,0 +1,6 @@
|
||||
encode: STR: 83fc61b6-b5ef-467f-9a15-89ddee668005
|
||||
INT: 175439308125737940688973558970912768005
|
||||
decode: variant: RFC 4122
|
||||
version: 4 (random data based)
|
||||
content: 83:fc:61:b6:b5:ef:46:7f:9a:15:89:dd:ee:66:80:05
|
||||
(no semantics: random data only)
|
||||
@@ -0,0 +1,6 @@
|
||||
encode: STR: 886313e1-3b8a-5372-9b90-0c9aee199e5d
|
||||
INT: 181289448026289383154478846676280385117
|
||||
decode: variant: RFC 4122
|
||||
version: 5 (name based, SHA-1)
|
||||
content: 88:63:13:e1:3b:8a:53:72:9b:90:0c:9a:ee:19:9e:5d
|
||||
(not decipherable: MD5 message digest only)
|
||||
Reference in New Issue
Block a user