Skip to content

Commit

Permalink
fixed tests when OpenSsl is not enabled in PHP, renamed a missnamed t…
Browse files Browse the repository at this point in the history
…est, added missing license doc blocks
  • Loading branch information
fabpot committed Oct 28, 2012
1 parent ca567b5 commit aecc9b1
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Security\Tests\Core\Util
{
use Symfony\Component\Security\Core\Util\ClassUtils;
Expand Down
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Security\Tests\Core\Util;

use Symfony\Component\Security\Core\Util\NullSeedProvider;
Expand Down Expand Up @@ -145,9 +154,14 @@ public function getSecureRandoms()
{
$secureRandoms = array();

// openssl with fallback
// openssl
$secureRandom = new SecureRandom();
$secureRandoms[] = array($secureRandom);
// only add if openssl is indeed present
if ($this->hasOpenSsl($secureRandom)) {
$secureRandoms[] = array($secureRandom);
} else {
$this->markTestSkipped('OpenSSL is not available');
}

// no-openssl with custom seed provider
$secureRandom = new SecureRandom(sys_get_temp_dir().'/_sf2.seed');
Expand All @@ -162,6 +176,19 @@ protected function disableOpenSsl($secureRandom)
$ref = new \ReflectionProperty($secureRandom, 'useOpenSsl');
$ref->setAccessible(true);
$ref->setValue($secureRandom, false);
$ref->setAccessible(false);
}

protected function hasOpenSsl($secureRandom)
{
$ref = new \ReflectionProperty($secureRandom, 'useOpenSsl');
$ref->setAccessible(true);

$ret = $ref->getValue($secureRandom);

$ref->setAccessible(false);

return $ret;
}

private function getBitSequence($secureRandom, $length)
Expand Down
@@ -1,10 +1,19 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Security\Tests\Core\Util;

use Symfony\Component\Security\Core\Util\StringUtils;

class StringTest extends \PHPUnit_Framework_TestCase
class StringUtilsTest extends \PHPUnit_Framework_TestCase
{
public function testEquals()
{
Expand Down

0 comments on commit aecc9b1

Please sign in to comment.