Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

Commit

Permalink
Make test for Crypt package run standalone.
Browse files Browse the repository at this point in the history
Refs #4
  • Loading branch information
eddieajau committed Mar 8, 2013
1 parent 8d30129 commit 0190944
Show file tree
Hide file tree
Showing 41 changed files with 70 additions and 39 deletions.
10 changes: 5 additions & 5 deletions vendor/Joomla/Crypt/Cipher.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ interface Cipher
/**
* Method to decrypt a data string.
*
* @param string $data The encrypted string to decrypt.
* @param JCryptKey $key The key[/pair] object to use for decryption.
* @param string $data The encrypted string to decrypt.
* @param Key $key The key[/pair] object to use for decryption.
*
* @return string The decrypted data string.
*
Expand All @@ -30,8 +30,8 @@ public function decrypt($data, Key $key);
/**
* Method to encrypt a data string.
*
* @param string $data The data string to encrypt.
* @param JCryptKey $key The key[/pair] object to use for encryption.
* @param string $data The data string to encrypt.
* @param Key $key The key[/pair] object to use for encryption.
*
* @return string The encrypted data string.
*
Expand All @@ -44,7 +44,7 @@ public function encrypt($data, Key $key);
*
* @param array $options Key generation options.
*
* @return JCryptKey
* @return Key
*
* @since 1.0
*/
Expand Down
1 change: 0 additions & 1 deletion vendor/Joomla/Crypt/Cipher/Blowfish.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Joomla\Crypt;


/**
* JCrypt cipher for Blowfish encryption, decryption and key generation.
*
Expand Down
12 changes: 4 additions & 8 deletions vendor/Joomla/Crypt/Cipher/Mcrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@

namespace Joomla\Crypt;


use RuntimeException;
use InvalidArgumentException;

/**
* JCrypt cipher for mcrypt algorithm encryption, decryption and key generation.
*
Expand Down Expand Up @@ -43,13 +39,13 @@ abstract class Cipher_Mcrypt implements Cipher
* Constructor.
*
* @since 1.0
* @throws RuntimeException
* @throws \RuntimeException
*/
public function __construct()
{
if (!is_callable('mcrypt_encrypt'))
{
throw new RuntimeException('The mcrypt extension is not available.');
throw new \RuntimeException('The mcrypt extension is not available.');
}
}

Expand All @@ -68,7 +64,7 @@ public function decrypt($data, Key $key)
// Validate key.
if ($key->type != $this->keyType)
{
throw new InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected ' . $this->keyType . '.');
throw new \InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected ' . $this->keyType . '.');
}

// Decrypt the data.
Expand All @@ -92,7 +88,7 @@ public function encrypt($data, Key $key)
// Validate key.
if ($key->type != $this->keyType)
{
throw new InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected ' . $this->keyType . '.');
throw new \InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected ' . $this->keyType . '.');
}

// Encrypt the data.
Expand Down
1 change: 0 additions & 1 deletion vendor/Joomla/Crypt/Cipher/Rijndael256.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Joomla\Crypt;


/**
* JCrypt cipher for Rijndael 256 encryption, decryption and key generation.
*
Expand Down
10 changes: 4 additions & 6 deletions vendor/Joomla/Crypt/Cipher/Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

namespace Joomla\Crypt;

use InvalidArgumentException;

/**
* JCrypt cipher for Simple encryption, decryption and key generation.
*
Expand All @@ -26,14 +24,14 @@ class Cipher_Simple implements Cipher
* @return string The decrypted data string.
*
* @since 1.0
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*/
public function decrypt($data, Key $key)
{
// Validate key.
if ($key->type != 'simple')
{
throw new InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected simple.');
throw new \InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected simple.');
}

$decrypted = '';
Expand Down Expand Up @@ -67,14 +65,14 @@ public function decrypt($data, Key $key)
* @return string The encrypted data string.
*
* @since 1.0
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*/
public function encrypt($data, Key $key)
{
// Validate key.
if ($key->type != 'simple')
{
throw new InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected simple.');
throw new \InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected simple.');
}

$encrypted = '';
Expand Down
16 changes: 8 additions & 8 deletions vendor/Joomla/Crypt/Crypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
namespace Joomla\Crypt;

/**
* JCrypt is a Joomla Platform class for handling basic encryption/decryption of data.
* Crypt is a Joomla Platform class for handling basic encryption/decryption of data.
*
* @package Joomla\Framework
* @since 1.0
*/
class Crypt
{
/**
* @var JCryptCipher The encryption cipher object.
* @var Cipher The encryption cipher object.
* @since 1.0
*/
private $cipher;

/**
* @var JCryptKey The encryption key[/pair)].
* @var Key The encryption key[/pair)].
* @since 1.0
*/
private $key;
Expand All @@ -31,8 +31,8 @@ class Crypt
* Object Constructor takes an optional key to be used for encryption/decryption. If no key is given then the
* secret word from the configuration object is used.
*
* @param JCryptCipher $cipher The encryption cipher object.
* @param JCryptKey $key The encryption key[/pair)].
* @param Cipher $cipher The encryption cipher object.
* @param Key $key The encryption key[/pair)].
*
* @since 1.0
*/
Expand Down Expand Up @@ -78,7 +78,7 @@ public function encrypt($data)
*
* @param array $options Key generation options.
*
* @return JCryptKey
* @return Key
*
* @since 1.0
*/
Expand All @@ -90,9 +90,9 @@ public function generateKey(array $options = array())
/**
* Method to set the encryption key[/pair] object.
*
* @param JCryptKey $key The key object to set.
* @param Key $key The key object to set.
*
* @return JCrypt
* @return Key
*
* @since 1.0
*/
Expand Down
3 changes: 1 addition & 2 deletions vendor/Joomla/Crypt/Password/Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace Joomla\Crypt\Password;

use Joomla\Crypt\Password;
use InvalidArgumentException;

/**
* Joomla Platform Password Crypter
Expand Down Expand Up @@ -79,7 +78,7 @@ public function create($password, $type = null)
return md5($password . $salt) . ':' . $salt;

default:
throw new InvalidArgumentException(sprintf('Hash type %s is not supported', $type));
throw new \InvalidArgumentException(sprintf('Hash type %s is not supported', $type));
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

namespace Joomla\Crypt\Tests;

use Joomla\Crypt\Key;
use Joomla\Crypt\Cipher_3DES;

/**
* Test class for JCryptCipher3DES.
*
* @package Joomla\Framework\Test
* @since 1.0
*/
class JCryptCipher3DESTest extends PHPUnit_Framework_TestCase
class Cipher3DESTest extends \PHPUnit_Framework_TestCase
{
/**
* @var JCryptCipher3DES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

namespace Joomla\Crypt\Tests;

use Joomla\Crypt\Key;
use Joomla\Crypt\Cipher_Blowfish;

Expand All @@ -14,7 +16,7 @@
* @package Joomla\Framework\Test
* @since 1.0
*/
class JCryptCipherBlowfishTest extends PHPUnit_Framework_TestCase
class CipherBlowfishTest extends \PHPUnit_Framework_TestCase
{
/**
* @var JCryptCipherBlowfish
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

namespace Joomla\Crypt\Tests;

use Joomla\Crypt\Key;
use Joomla\Crypt\Cipher_Rijndael256;

Expand All @@ -14,7 +16,7 @@
* @package Joomla\Framework\Test
* @since 1.0
*/
class JCryptCipherRijndael256Test extends PHPUnit_Framework_TestCase
class CipherRijndael256Test extends \PHPUnit_Framework_TestCase
{
/**
* @var JCryptCipherRijndael256
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

namespace Joomla\Crypt\Tests;

use Joomla\Crypt\Key;
use Joomla\Crypt\Cipher_Simple;

Expand All @@ -14,7 +16,7 @@
* @package Joomla\Framework\Test
* @since 1.0
*/
class JCryptCipherSimpleTest extends PHPUnit_Framework_TestCase
class CipherSimpleTest extends \PHPUnit_Framework_TestCase
{
/**
* @var JCryptCipherSimple
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

namespace Joomla\Crypt\Tests;

use Joomla\Crypt\Crypt;

/**
* Test class for JCrypt.
* Generated by PHPUnit on 2012-03-21 at 21:17:14.
*
* @package Joomla\Framework\Test
* @since 1.0
*/
class CryptTest extends PHPUnit_Framework_TestCase
class CryptTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Joomla\Crypt\Crypt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

namespace Joomla\Crypt\Tests;

use Joomla\Crypt\Password;
use Joomla\Crypt\Password\Simple;
use Joomla\Test\Helper;

/**
* Test class for JCryptPasswordSimple.
*
* @package Joomla\Framework\Test
* @since 1.0
*/
class JCryptPasswordSimpleTest extends PHPUnit_Framework_TestCase
class PasswordSimpleTest extends \PHPUnit_Framework_TestCase
{
/**
* Data provider for testCreate method.
Expand Down Expand Up @@ -192,7 +195,7 @@ public function testSetDefaultType($type, $expectation)
$test = new Simple;
$test->setDefaultType($type);
$this->assertThat(
TestReflection::getValue($test, 'defaultType'),
Helper::getValue($test, 'defaultType'),
$this->equalTo($expectation)
);
}
Expand Down
19 changes: 19 additions & 0 deletions vendor/Joomla/Crypt/Tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* @package Joomla\Framework\Test
* @copyright Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

// Search for the Composer autoload file
$composerAutoload = __DIR__ . '/../../../../../autoload.php';

if (file_exists($composerAutoload))
{
include_once $composerAutoload;
}
else
// We're not installed via composer, so load our own autoloader.
{
include_once __DIR__ . '/../../../../tests/bootstrap.php';
}
8 changes: 8 additions & 0 deletions vendor/Joomla/Crypt/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="Tests/bootstrap.php" colors="false">
<testsuites>
<testsuite name="Unit">
<directory>Tests</directory>
</testsuite>
</testsuites>
</phpunit>

0 comments on commit 0190944

Please sign in to comment.