Add Symfony Deprecation Contracts package
- Created CHANGELOG.md to maintain version history. - Added README.md with usage instructions for the trigger_deprecation() function. - Initialized composer.json for the Symfony Deprecation Contracts library, specifying dependencies and autoloading.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The RandomLib library for securely generating random numbers and strings in PHP
|
||||
*
|
||||
* @author Anthony Ferrara <ircmaxell@ircmaxell.com>
|
||||
* @copyright 2011 The Authors
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version Build @@version@@
|
||||
*/
|
||||
namespace RandomLib\Mixer;
|
||||
|
||||
use SecurityLib\Strength;
|
||||
|
||||
class HashTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public static function provideMix()
|
||||
{
|
||||
$data = array(
|
||||
array(array(), ''),
|
||||
array(array('1', '1'), '0d'),
|
||||
array(array('a'), '61'),
|
||||
// This expects 'b' because of how the mock hmac function works
|
||||
array(array('a', 'b'), '9a'),
|
||||
array(array('aa', 'ba'), '6e84'),
|
||||
array(array('ab', 'bb'), 'b0cb'),
|
||||
array(array('aa', 'bb'), 'ae8d'),
|
||||
array(array('aa', 'bb', 'cc'), 'a14c'),
|
||||
array(array('aabbcc', 'bbccdd', 'ccddee'), 'a8aff3939934'),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function testConstructWithoutArgument()
|
||||
{
|
||||
$hash = new Hash();
|
||||
$this->assertTrue($hash instanceof \RandomLib\Mixer);
|
||||
}
|
||||
|
||||
public function testGetStrength()
|
||||
{
|
||||
$strength = new Strength(Strength::MEDIUM);
|
||||
$actual = Hash::getStrength();
|
||||
$this->assertEquals($actual, $strength);
|
||||
}
|
||||
|
||||
public function testTest()
|
||||
{
|
||||
$actual = Hash::test();
|
||||
$this->assertTrue($actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideMix
|
||||
*/
|
||||
public function testMix($parts, $result)
|
||||
{
|
||||
$mixer = new Hash('md5');
|
||||
$actual = $mixer->mix($parts);
|
||||
$this->assertEquals($result, bin2hex($actual));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The RandomLib library for securely generating random numbers and strings in PHP
|
||||
*
|
||||
* @author Anthony Ferrara <ircmaxell@ircmaxell.com>
|
||||
* @copyright 2011 The Authors
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version Build @@version@@
|
||||
*/
|
||||
namespace RandomLib\Mixer;
|
||||
|
||||
use SecurityLib\Strength;
|
||||
|
||||
class McryptRijndael128Test extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public static function provideMix()
|
||||
{
|
||||
$data = array(
|
||||
array(array(), ''),
|
||||
array(array('', ''), ''),
|
||||
array(array('a'), '61'),
|
||||
array(array('a', 'b'), '6a'),
|
||||
array(array('aa', 'ba'), '688d'),
|
||||
array(array('ab', 'bb'), 'f8bc'),
|
||||
array(array('aa', 'bb'), 'a0f3'),
|
||||
array(array('aa', 'bb', 'cc'), '87c3'),
|
||||
array(array('aabbcc', 'bbccdd', 'ccddee'), '7cf2273e46c7'),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!\extension_loaded('mcrypt') || PHP_VERSION_ID >= 70100) {
|
||||
$this->markTestSkipped('mcrypt extension is not available');
|
||||
}
|
||||
}
|
||||
|
||||
public function testConstructWithoutArgument()
|
||||
{
|
||||
$hash = new McryptRijndael128();
|
||||
$this->assertTrue($hash instanceof \RandomLib\Mixer);
|
||||
}
|
||||
|
||||
public function testGetStrength()
|
||||
{
|
||||
$strength = new Strength(Strength::HIGH);
|
||||
$actual = McryptRijndael128::getStrength();
|
||||
$this->assertEquals($actual, $strength);
|
||||
}
|
||||
|
||||
public function testTest()
|
||||
{
|
||||
$actual = McryptRijndael128::test();
|
||||
$this->assertTrue($actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideMix
|
||||
*/
|
||||
public function testMix($parts, $result)
|
||||
{
|
||||
$mixer = new McryptRijndael128();
|
||||
$actual = $mixer->mix($parts);
|
||||
$this->assertEquals($result, bin2hex($actual));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The RandomLib library for securely generating random numbers and strings in PHP
|
||||
*
|
||||
* @author Anthony Ferrara <ircmaxell@ircmaxell.com>
|
||||
* @copyright 2011 The Authors
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version Build @@version@@
|
||||
*/
|
||||
namespace RandomLib\Mixer;
|
||||
|
||||
use SecurityLib\Strength;
|
||||
|
||||
class SodiumTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public static function provideMix()
|
||||
{
|
||||
$data = array(
|
||||
array(array(), ''),
|
||||
array(array('', ''), ''),
|
||||
array(array('a'), '61'),
|
||||
array(array('a', 'b'), '44'),
|
||||
array(array('aa', 'ba'), '6967'),
|
||||
array(array('ab', 'bb'), '73a6'),
|
||||
array(array('aa', 'bb'), 'bc7b'),
|
||||
array(array('aa', 'bb', 'cc'), '0cbd'),
|
||||
array(array('aabbcc', 'bbccdd', 'ccddee'), '5f0005cacd7c'),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!\is_callable('sodium_crypto_generichash') || defined('HHVM_VERSION')) {
|
||||
$this->markTestSkipped('sodium extension is not available');
|
||||
}
|
||||
}
|
||||
|
||||
public function testConstructWithoutArgument()
|
||||
{
|
||||
$hash = new SodiumMixer();
|
||||
$this->assertTrue($hash instanceof \RandomLib\Mixer);
|
||||
}
|
||||
|
||||
public function testGetStrength()
|
||||
{
|
||||
$strength = new Strength(Strength::HIGH);
|
||||
$actual = SodiumMixer::getStrength();
|
||||
$this->assertEquals($actual, $strength);
|
||||
}
|
||||
|
||||
public function testTest()
|
||||
{
|
||||
$actual = SodiumMixer::test();
|
||||
$this->assertTrue($actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideMix
|
||||
*/
|
||||
public function testMix($parts, $result)
|
||||
{
|
||||
$mixer = new SodiumMixer();
|
||||
$actual = $mixer->mix($parts);
|
||||
$this->assertEquals($result, bin2hex($actual));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user