diff --git a/.travis.yml b/.travis.yml
index 710e1579..fd595a9e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,7 +19,8 @@ before_script:
- sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then composer install --dev --no-interaction; fi"
script:
- - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then vendor/bin/phpcs -s --extensions=php --standard=tests/code_sniffer_ruleset.xml phpseclib/; fi"
+ - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then vendor/bin/phpcs -s --extensions=php --standard=build/code-sniffer-ruleset.xml phpseclib/; fi"
+ - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then vendor/bin/phpcs -s --extensions=php --standard=build/code-sniffer-ruleset-tests.xml tests/; fi"
- phpunit --verbose --coverage-text --coverage-html code_coverage/
after_success:
diff --git a/build/code-sniffer-ruleset-tests.xml b/build/code-sniffer-ruleset-tests.xml
new file mode 100644
index 00000000..c3694258
--- /dev/null
+++ b/build/code-sniffer-ruleset-tests.xml
@@ -0,0 +1,21 @@
+
+
+
+ phpseclib coding standard for tests
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build/code-sniffer-ruleset.xml b/build/code-sniffer-ruleset.xml
new file mode 100644
index 00000000..9da1625a
--- /dev/null
+++ b/build/code-sniffer-ruleset.xml
@@ -0,0 +1,76 @@
+
+
+
+ phpseclib coding standard
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/composer.lock b/composer.lock
index 2bdf3602..1b5ff07e 100644
--- a/composer.lock
+++ b/composer.lock
@@ -3,23 +3,23 @@
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
],
- "hash": "e692359d277b10176319a11c2aef51aa",
+ "hash": "4975b8cde04a99d6e78e108753845af6",
"packages": [
],
"packages-dev": [
{
"name": "squizlabs/php_codesniffer",
- "version": "1.4.7",
+ "version": "1.5.2",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
- "reference": "df764a1604607ea61c4eeea5410666e27cb37a8b"
+ "reference": "a76a39b317ce8106abe6264daa505e24e1731860"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/df764a1604607ea61c4eeea5410666e27cb37a8b",
- "reference": "df764a1604607ea61c4eeea5410666e27cb37a8b",
+ "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/a76a39b317ce8106abe6264daa505e24e1731860",
+ "reference": "a76a39b317ce8106abe6264daa505e24e1731860",
"shasum": ""
},
"require": {
@@ -39,7 +39,6 @@
"CodeSniffer/CLI.php",
"CodeSniffer/Exception.php",
"CodeSniffer/File.php",
- "CodeSniffer/MultiFileSniff.php",
"CodeSniffer/Report.php",
"CodeSniffer/Reporting.php",
"CodeSniffer/Sniff.php",
@@ -77,7 +76,7 @@
"phpcs",
"standards"
],
- "time": "2013-09-26 00:08:21"
+ "time": "2014-02-04 23:49:58"
}
],
"aliases": [
diff --git a/tests/Crypt/AES/ContinuousBufferTest.php b/tests/Crypt/AES/ContinuousBufferTest.php
index 2d7185b3..1d712597 100644
--- a/tests/Crypt/AES/ContinuousBufferTest.php
+++ b/tests/Crypt/AES/ContinuousBufferTest.php
@@ -1,71 +1,72 @@
- * @copyright MMXIII Andreas Fischer
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @author Andreas Fischer
+ * @copyright MMXIII Andreas Fischer
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
class Crypt_AES_ContinuousBufferTest extends Crypt_AES_TestCase
{
- // String intented
- protected $modes = array(
- 'CRYPT_AES_MODE_CTR',
- 'CRYPT_AES_MODE_OFB',
- 'CRYPT_AES_MODE_CFB',
- );
+ // String intented
+ protected $modes = array(
+ 'CRYPT_AES_MODE_CTR',
+ 'CRYPT_AES_MODE_OFB',
+ 'CRYPT_AES_MODE_CFB',
+ );
- protected $plaintexts = array(
- '',
- '12345678901234567', // https://github.com/phpseclib/phpseclib/issues/39
- "\xDE\xAD\xBE\xAF",
- ':-):-):-):-):-):-)', // https://github.com/phpseclib/phpseclib/pull/43
- );
+ protected $plaintexts = array(
+ '',
+ '12345678901234567', // https://github.com/phpseclib/phpseclib/issues/39
+ "\xDE\xAD\xBE\xAF",
+ ':-):-):-):-):-):-)', // https://github.com/phpseclib/phpseclib/pull/43
+ );
- protected $ivs = array(
- '',
- 'test123',
- );
+ protected $ivs = array(
+ '',
+ 'test123',
+ );
- protected $keys = array(
- '',
- ':-8', // https://github.com/phpseclib/phpseclib/pull/43
- 'FOOBARZ',
- );
+ protected $keys = array(
+ '',
+ ':-8', // https://github.com/phpseclib/phpseclib/pull/43
+ 'FOOBARZ',
+ );
- /**
- * Produces all combinations of test values.
- *
- * @return array
- */
- public function allCombinations()
- {
- $result = array();
+ /**
+ * Produces all combinations of test values.
+ *
+ * @return array
+ */
+ public function allCombinations()
+ {
+ $result = array();
- foreach ($this->modes as $mode)
- foreach ($this->plaintexts as $plaintext)
- foreach ($this->ivs as $iv)
- foreach ($this->keys as $key)
- $result[] = array($mode, $plaintext, $iv, $key);
+ // @codingStandardsIgnoreStart
+ foreach ($this->modes as $mode)
+ foreach ($this->plaintexts as $plaintext)
+ foreach ($this->ivs as $iv)
+ foreach ($this->keys as $key)
+ $result[] = array($mode, $plaintext, $iv, $key);
+ // @codingStandardsIgnoreEnd
- return $result;
- }
+ return $result;
+ }
- /**
- * @dataProvider allCombinations
- */
- public function testEncryptDecrypt($mode, $plaintext, $iv, $key)
- {
- $aes = new Crypt_AES(constant($mode));
- $aes->enableContinuousBuffer();
- $aes->setIV($iv);
- $aes->setKey($key);
+ /**
+ * @dataProvider allCombinations
+ */
+ public function testEncryptDecrypt($mode, $plaintext, $iv, $key)
+ {
+ $aes = new Crypt_AES(constant($mode));
+ $aes->enableContinuousBuffer();
+ $aes->setIV($iv);
+ $aes->setKey($key);
- $actual = '';
- for ($i = 0, $strlen = strlen($plaintext); $i < $strlen; ++$i)
- {
- $actual .= $aes->decrypt($aes->encrypt($plaintext[$i]));
- }
+ $actual = '';
+ for ($i = 0, $strlen = strlen($plaintext); $i < $strlen; ++$i) {
+ $actual .= $aes->decrypt($aes->encrypt($plaintext[$i]));
+ }
- $this->assertEquals($plaintext, $actual);
- }
+ $this->assertEquals($plaintext, $actual);
+ }
}
diff --git a/tests/Crypt/AES/TestCase.php b/tests/Crypt/AES/TestCase.php
index f845e4bb..317f1e52 100644
--- a/tests/Crypt/AES/TestCase.php
+++ b/tests/Crypt/AES/TestCase.php
@@ -1,27 +1,27 @@
- * @copyright MMXIII Andreas Fischer
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @author Andreas Fischer
+ * @copyright MMXIII Andreas Fischer
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
+require_once 'Crypt/AES.php';
+
abstract class Crypt_AES_TestCase extends PhpseclibTestCase
{
- static public function setUpBeforeClass()
- {
- require_once('Crypt/AES.php');
+ static public function setUpBeforeClass()
+ {
+ if (!defined('CRYPT_AES_MODE')) {
+ define('CRYPT_AES_MODE', CRYPT_AES_MODE_INTERNAL);
+ }
+ }
- if (!defined('CRYPT_AES_MODE'))
- {
- define('CRYPT_AES_MODE', CRYPT_AES_MODE_INTERNAL);
- }
- }
-
- public function setUp()
- {
- if (defined('CRYPT_AES_MODE') && CRYPT_AES_MODE !== CRYPT_AES_MODE_INTERNAL)
- {
- $this->markTestSkipped('Skipping test because CRYPT_AES_MODE is not defined as CRYPT_AES_MODE_INTERNAL.');
- }
- }
+ public function setUp()
+ {
+ if (defined('CRYPT_AES_MODE') && CRYPT_AES_MODE !== CRYPT_AES_MODE_INTERNAL) {
+ $this->markTestSkipped(
+ 'Skipping test because CRYPT_AES_MODE is not defined as CRYPT_AES_MODE_INTERNAL.'
+ );
+ }
+ }
}
diff --git a/tests/Crypt/Hash/MD5Test.php b/tests/Crypt/Hash/MD5Test.php
index 41fc20a9..4b0635de 100644
--- a/tests/Crypt/Hash/MD5Test.php
+++ b/tests/Crypt/Hash/MD5Test.php
@@ -1,47 +1,47 @@
- * @copyright MMXII Andreas Fischer
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @author Andreas Fischer
+ * @copyright MMXII Andreas Fischer
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
class Crypt_Hash_MD5Test extends Crypt_Hash_TestCase
{
- public function getInstance()
- {
- return new Crypt_Hash('md5');
- }
+ public function getInstance()
+ {
+ return new Crypt_Hash('md5');
+ }
- /**
- * @dataProvider hashData()
- */
- public function testHash($message, $result)
- {
- $this->assertHashesTo($this->getInstance(), $message, $result);
- }
+ /**
+ * @dataProvider hashData()
+ */
+ public function testHash($message, $result)
+ {
+ $this->assertHashesTo($this->getInstance(), $message, $result);
+ }
- static public function hashData()
- {
- return array(
- array('', 'd41d8cd98f00b204e9800998ecf8427e'),
- array('The quick brown fox jumps over the lazy dog', '9e107d9d372bb6826bd81d3542a419d6'),
- array('The quick brown fox jumps over the lazy dog.', 'e4d909c290d0fb1ca068ffaddf22cbd0'),
- );
- }
+ static public function hashData()
+ {
+ return array(
+ array('', 'd41d8cd98f00b204e9800998ecf8427e'),
+ array('The quick brown fox jumps over the lazy dog', '9e107d9d372bb6826bd81d3542a419d6'),
+ array('The quick brown fox jumps over the lazy dog.', 'e4d909c290d0fb1ca068ffaddf22cbd0'),
+ );
+ }
- /**
- * @dataProvider hmacData()
- */
- public function testHMAC($key, $message, $result)
- {
- $this->assertHMACsTo($this->getInstance(), $key, $message, $result);
- }
+ /**
+ * @dataProvider hmacData()
+ */
+ public function testHMAC($key, $message, $result)
+ {
+ $this->assertHMACsTo($this->getInstance(), $key, $message, $result);
+ }
- static public function hmacData()
- {
- return array(
- array('', '', '74e6f7298a9c2d168935f58c001bad88'),
- array('key', 'The quick brown fox jumps over the lazy dog', '80070713463e7749b90c2dc24911e275'),
- );
- }
+ static public function hmacData()
+ {
+ return array(
+ array('', '', '74e6f7298a9c2d168935f58c001bad88'),
+ array('key', 'The quick brown fox jumps over the lazy dog', '80070713463e7749b90c2dc24911e275'),
+ );
+ }
}
diff --git a/tests/Crypt/Hash/TestCase.php b/tests/Crypt/Hash/TestCase.php
index 5f61244c..5f469751 100644
--- a/tests/Crypt/Hash/TestCase.php
+++ b/tests/Crypt/Hash/TestCase.php
@@ -1,47 +1,52 @@
- * @copyright MMXII Andreas Fischer
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @author Andreas Fischer
+ * @copyright MMXII Andreas Fischer
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
+require_once 'Crypt/Hash.php';
+
abstract class Crypt_Hash_TestCase extends PhpseclibTestCase
{
- static public function setUpBeforeClass()
- {
- require_once('Crypt/Hash.php');
+ static public function setUpBeforeClass()
+ {
+ if (!defined('CRYPT_HASH_MODE')) {
+ define('CRYPT_HASH_MODE', CRYPT_HASH_MODE_INTERNAL);
+ }
+ }
- if (!defined('CRYPT_HASH_MODE'))
- {
- define('CRYPT_HASH_MODE', CRYPT_HASH_MODE_INTERNAL);
- }
- }
+ public function setUp()
+ {
+ if (defined('CRYPT_HASH_MODE') && CRYPT_HASH_MODE !== CRYPT_HASH_MODE_INTERNAL) {
+ $this->markTestSkipped(
+ 'Skipping test because CRYPT_HASH_MODE is not defined as CRYPT_HASH_MODE_INTERNAL.'
+ );
+ }
+ }
- public function setUp()
- {
- if (defined('CRYPT_HASH_MODE') && CRYPT_HASH_MODE !== CRYPT_HASH_MODE_INTERNAL)
- {
- $this->markTestSkipped('Skipping test because CRYPT_HASH_MODE is not defined as CRYPT_HASH_MODE_INTERNAL.');
- }
- }
+ protected function assertHashesTo(Crypt_Hash $hash, $message, $expected)
+ {
+ $this->assertEquals(
+ strtolower($expected),
+ bin2hex($hash->hash($message)),
+ sprintf("Failed asserting that '%s' hashes to '%s'.", $message, $expected)
+ );
+ }
- protected function assertHashesTo(Crypt_Hash $hash, $message, $expected)
- {
- $this->assertEquals(
- strtolower($expected),
- bin2hex($hash->hash($message)),
- sprintf("Failed asserting that '%s' hashes to '%s'.", $message, $expected)
- );
- }
+ protected function assertHMACsTo(Crypt_Hash $hash, $key, $message, $expected)
+ {
+ $hash->setKey($key);
- protected function assertHMACsTo(Crypt_Hash $hash, $key, $message, $expected)
- {
- $hash->setKey($key);
-
- $this->assertEquals(
- strtolower($expected),
- bin2hex($hash->hash($message)),
- sprintf("Failed asserting that '%s' HMACs to '%s' with key '%s'.", $message, $expected, $key)
- );
- }
+ $this->assertEquals(
+ strtolower($expected),
+ bin2hex($hash->hash($message)),
+ sprintf(
+ "Failed asserting that '%s' HMACs to '%s' with key '%s'.",
+ $message,
+ $expected,
+ $key
+ )
+ );
+ }
}
diff --git a/tests/Crypt/RSA/LoadKeyTest.php b/tests/Crypt/RSA/LoadKeyTest.php
index 9ef33065..95239d84 100644
--- a/tests/Crypt/RSA/LoadKeyTest.php
+++ b/tests/Crypt/RSA/LoadKeyTest.php
@@ -1,31 +1,28 @@
- * @copyright MMXIII Jim Wigginton
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @author Jim Wigginton
+ * @copyright MMXIII Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
+require_once 'Crypt/RSA.php' ;
+
class Crypt_RSA_LoadKeyTest extends PhpseclibTestCase
{
- static public function setUpBeforeClass()
- {
- require_once('Crypt/RSA.php');
- }
+ public function testBadKey()
+ {
+ $rsa = new Crypt_RSA();
- public function testBadKey()
- {
- $rsa = new Crypt_RSA();
+ $key = 'zzzzzzzzzzzzzz';
- $key = 'zzzzzzzzzzzzzz';
+ $this->assertFalse($rsa->loadKey($key));
+ }
- $this->assertFalse($rsa->loadKey($key));
- }
+ public function testPKCS1Key()
+ {
+ $rsa = new Crypt_RSA();
- public function testPKCS1Key()
- {
- $rsa = new Crypt_RSA();
-
- $key = '-----BEGIN RSA PRIVATE KEY-----
+ $key = '-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp
wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5
1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh
@@ -39,14 +36,14 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=
-----END RSA PRIVATE KEY-----';
- $this->assertTrue($rsa->loadKey($key));
- }
+ $this->assertTrue($rsa->loadKey($key));
+ }
- public function testPKCS1SpacesKey()
- {
- $rsa = new Crypt_RSA();
+ public function testPKCS1SpacesKey()
+ {
+ $rsa = new Crypt_RSA();
- $key = '-----BEGIN RSA PRIVATE KEY-----
+ $key = '-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp
wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5
1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh
@@ -59,16 +56,16 @@ X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl
U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=
-----END RSA PRIVATE KEY-----';
- $key = str_replace(array("\r", "\n", "\r\n"), ' ', $key);
+ $key = str_replace(array("\r", "\n", "\r\n"), ' ', $key);
- $this->assertTrue($rsa->loadKey($key));
- }
+ $this->assertTrue($rsa->loadKey($key));
+ }
- public function testPKCS1NoHeaderKey()
- {
- $rsa = new Crypt_RSA();
+ public function testPKCS1NoHeaderKey()
+ {
+ $rsa = new Crypt_RSA();
- $key = 'MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp
+ $key = 'MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp
wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5
1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh
3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2
@@ -80,44 +77,44 @@ X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl
U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=';
- $this->assertTrue($rsa->loadKey($key));
- }
+ $this->assertTrue($rsa->loadKey($key));
+ }
- public function testPKCS1NoWhitespaceNoHeaderKey()
- {
- $rsa = new Crypt_RSA();
+ public function testPKCS1NoWhitespaceNoHeaderKey()
+ {
+ $rsa = new Crypt_RSA();
- $key = 'MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp' .
- 'wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5' .
- '1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh' .
- '3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2' .
- 'pIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX' .
- 'GukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il' .
- 'AkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF' .
- 'L0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k' .
- 'X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl' .
- 'U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ' .
- '37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=';
- $this->assertTrue($rsa->loadKey($key));
- }
+ $key = 'MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp' .
+ 'wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5' .
+ '1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh' .
+ '3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2' .
+ 'pIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX' .
+ 'GukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il' .
+ 'AkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF' .
+ 'L0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k' .
+ 'X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl' .
+ 'U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ' .
+ '37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=';
+ $this->assertTrue($rsa->loadKey($key));
+ }
- public function testRawPKCS1Key()
- {
- $rsa = new Crypt_RSA();
+ public function testRawPKCS1Key()
+ {
+ $rsa = new Crypt_RSA();
- $key = 'MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp' .
- 'wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5' .
- '1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh' .
- '3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2' .
- 'pIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX' .
- 'GukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il' .
- 'AkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF' .
- 'L0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k' .
- 'X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl' .
- 'U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ' .
- '37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=';
- $key = base64_decode($key);
+ $key = 'MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp' .
+ 'wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5' .
+ '1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh' .
+ '3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2' .
+ 'pIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX' .
+ 'GukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il' .
+ 'AkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF' .
+ 'L0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k' .
+ 'X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl' .
+ 'U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ' .
+ '37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=';
+ $key = base64_decode($key);
- $this->assertTrue($rsa->loadKey($key));
- }
+ $this->assertTrue($rsa->loadKey($key));
+ }
}
diff --git a/tests/Math/BigInteger/BCMathTest.php b/tests/Math/BigInteger/BCMathTest.php
index f97fac93..72c574d1 100644
--- a/tests/Math/BigInteger/BCMathTest.php
+++ b/tests/Math/BigInteger/BCMathTest.php
@@ -1,21 +1,20 @@
- * @copyright MMXIII Andreas Fischer
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @author Andreas Fischer
+ * @copyright MMXIII Andreas Fischer
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
class Math_BigInteger_BCMathTest extends Math_BigInteger_TestCase
{
- static public function setUpBeforeClass()
- {
- if (!extension_loaded('bcmath'))
- {
- self::markTestSkipped('BCMath extension is not available.');
- }
+ static public function setUpBeforeClass()
+ {
+ if (!extension_loaded('bcmath')) {
+ self::markTestSkipped('BCMath extension is not available.');
+ }
- parent::setUpBeforeClass();
+ parent::setUpBeforeClass();
- self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH);
- }
+ self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH);
+ }
}
diff --git a/tests/Math/BigInteger/GMPTest.php b/tests/Math/BigInteger/GMPTest.php
index a0074db5..27c7a6a4 100644
--- a/tests/Math/BigInteger/GMPTest.php
+++ b/tests/Math/BigInteger/GMPTest.php
@@ -1,21 +1,20 @@
- * @copyright MMXIII Andreas Fischer
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @author Andreas Fischer
+ * @copyright MMXIII Andreas Fischer
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
class Math_BigInteger_GMPTest extends Math_BigInteger_TestCase
{
- static public function setUpBeforeClass()
- {
- if (!extension_loaded('gmp'))
- {
- self::markTestSkipped('GNU Multiple Precision (GMP) extension is not available.');
- }
+ static public function setUpBeforeClass()
+ {
+ if (!extension_loaded('gmp')) {
+ self::markTestSkipped('GNU Multiple Precision (GMP) extension is not available.');
+ }
- parent::setUpBeforeClass();
+ parent::setUpBeforeClass();
- self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_GMP);
- }
+ self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_GMP);
+ }
}
diff --git a/tests/Math/BigInteger/InternalOpenSSLTest.php b/tests/Math/BigInteger/InternalOpenSSLTest.php
index f235484d..378caacc 100644
--- a/tests/Math/BigInteger/InternalOpenSSLTest.php
+++ b/tests/Math/BigInteger/InternalOpenSSLTest.php
@@ -1,21 +1,20 @@
- * @copyright MMXIII Andreas Fischer
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @author Andreas Fischer
+ * @copyright MMXIII Andreas Fischer
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
class Math_BigInteger_InternalOpenSSLTest extends Math_BigInteger_TestCase
{
- static public function setUpBeforeClass()
- {
- if (!function_exists('openssl_public_encrypt'))
- {
- self::markTestSkipped('openssl_public_encrypt() function is not available.');
- }
+ static public function setUpBeforeClass()
+ {
+ if (!function_exists('openssl_public_encrypt')) {
+ self::markTestSkipped('openssl_public_encrypt() function is not available.');
+ }
- parent::setUpBeforeClass();
+ parent::setUpBeforeClass();
- self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL);
- }
+ self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL);
+ }
}
diff --git a/tests/Math/BigInteger/InternalTest.php b/tests/Math/BigInteger/InternalTest.php
index 7cbbc8f8..b0292319 100644
--- a/tests/Math/BigInteger/InternalTest.php
+++ b/tests/Math/BigInteger/InternalTest.php
@@ -1,17 +1,17 @@
- * @copyright MMXIII Andreas Fischer
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @author Andreas Fischer
+ * @copyright MMXIII Andreas Fischer
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
class Math_BigInteger_InternalTest extends Math_BigInteger_TestCase
{
- static public function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
+ static public function setUpBeforeClass()
+ {
+ parent::setUpBeforeClass();
- self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL);
- self::ensureConstant('MATH_BIGINTEGER_OPENSSL_DISABLE', true);
- }
+ self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL);
+ self::ensureConstant('MATH_BIGINTEGER_OPENSSL_DISABLE', true);
+ }
}
diff --git a/tests/Math/BigInteger/TestCase.php b/tests/Math/BigInteger/TestCase.php
index ceac1f4a..ea9d4e2b 100644
--- a/tests/Math/BigInteger/TestCase.php
+++ b/tests/Math/BigInteger/TestCase.php
@@ -1,268 +1,268 @@
- * @copyright MMXII Andreas Fischer
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @author Andreas Fischer
+ * @copyright MMXII Andreas Fischer
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
require_once 'Math/BigInteger.php';
abstract class Math_BigInteger_TestCase extends PhpseclibTestCase
{
- static public function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
+ static public function setUpBeforeClass()
+ {
+ parent::setUpBeforeClass();
- self::reRequireFile('Math/BigInteger.php');
- }
+ self::reRequireFile('Math/BigInteger.php');
+ }
- public function getInstance($x = 0, $base = 10)
- {
- return new Math_BigInteger($x, $base);
- }
+ public function getInstance($x = 0, $base = 10)
+ {
+ return new Math_BigInteger($x, $base);
+ }
- public function testConstructorBase2()
- {
- // 2**65 = 36893488147419103232
- $this->assertSame('36893488147419103232', (string) $this->getInstance('1' . str_repeat('0', 65), 2));
- }
+ public function testConstructorBase2()
+ {
+ // 2**65 = 36893488147419103232
+ $this->assertSame('36893488147419103232', (string) $this->getInstance('1' . str_repeat('0', 65), 2));
+ }
- public function testConstructorBase10()
- {
- $this->assertSame('18446744073709551616', (string) $this->getInstance('18446744073709551616'));
- }
+ public function testConstructorBase10()
+ {
+ $this->assertSame('18446744073709551616', (string) $this->getInstance('18446744073709551616'));
+ }
- public function testConstructorBase16()
- {
- $this->assertSame('50', (string) $this->getInstance('0x32', 16));
- $this->assertSame('12345678910', (string) $this->getInstance('0x2DFDC1C3E', 16));
- $this->assertSame('18446744073709551615', (string) $this->getInstance('0xFFFFFFFFFFFFFFFF', 16));
- $this->assertSame('18446744073709551616', (string) $this->getInstance('0x10000000000000000', 16));
- }
+ public function testConstructorBase16()
+ {
+ $this->assertSame('50', (string) $this->getInstance('0x32', 16));
+ $this->assertSame('12345678910', (string) $this->getInstance('0x2DFDC1C3E', 16));
+ $this->assertSame('18446744073709551615', (string) $this->getInstance('0xFFFFFFFFFFFFFFFF', 16));
+ $this->assertSame('18446744073709551616', (string) $this->getInstance('0x10000000000000000', 16));
+ }
- public function testToBytes()
- {
- $this->assertSame(chr(65), $this->getInstance('65')->toBytes());
- }
+ public function testToBytes()
+ {
+ $this->assertSame(chr(65), $this->getInstance('65')->toBytes());
+ }
- public function testToBytesTwosCompliment()
- {
- $this->assertSame(chr(126), $this->getInstance('01111110', 2)->toBytes(true));
- }
+ public function testToBytesTwosCompliment()
+ {
+ $this->assertSame(chr(126), $this->getInstance('01111110', 2)->toBytes(true));
+ }
- public function testToHex()
- {
- $this->assertSame('41', $this->getInstance('65')->toHex());
- }
+ public function testToHex()
+ {
+ $this->assertSame('41', $this->getInstance('65')->toHex());
+ }
- public function testToBits()
- {
- $this->assertSame('1000001', $this->getInstance('65')->toBits());
- }
+ public function testToBits()
+ {
+ $this->assertSame('1000001', $this->getInstance('65')->toBits());
+ }
- public function testAdd()
- {
- $x = $this->getInstance('18446744073709551615');
- $y = $this->getInstance( '100000000000');
+ public function testAdd()
+ {
+ $x = $this->getInstance('18446744073709551615');
+ $y = $this->getInstance( '100000000000');
- $a = $x->add($y);
- $b = $y->add($x);
+ $a = $x->add($y);
+ $b = $y->add($x);
- $this->assertTrue($a->equals($b));
- $this->assertTrue($b->equals($a));
+ $this->assertTrue($a->equals($b));
+ $this->assertTrue($b->equals($a));
- $this->assertSame('18446744173709551615', (string) $a);
- $this->assertSame('18446744173709551615', (string) $b);
- }
+ $this->assertSame('18446744173709551615', (string) $a);
+ $this->assertSame('18446744173709551615', (string) $b);
+ }
- public function testSubtract()
- {
- $x = $this->getInstance('18446744073709551618');
- $y = $this->getInstance( '4000000000000');
- $this->assertSame('18446740073709551618', (string) $x->subtract($y));
- }
+ public function testSubtract()
+ {
+ $x = $this->getInstance('18446744073709551618');
+ $y = $this->getInstance( '4000000000000');
+ $this->assertSame('18446740073709551618', (string) $x->subtract($y));
+ }
- public function testMultiply()
- {
- $x = $this->getInstance('8589934592'); // 2**33
- $y = $this->getInstance('36893488147419103232'); // 2**65
+ public function testMultiply()
+ {
+ $x = $this->getInstance('8589934592'); // 2**33
+ $y = $this->getInstance('36893488147419103232'); // 2**65
- $a = $x->multiply($y); // 2**98
- $b = $y->multiply($x); // 2**98
+ $a = $x->multiply($y); // 2**98
+ $b = $y->multiply($x); // 2**98
- $this->assertTrue($a->equals($b));
- $this->assertTrue($b->equals($a));
+ $this->assertTrue($a->equals($b));
+ $this->assertTrue($b->equals($a));
- $this->assertSame('316912650057057350374175801344', (string) $a);
- $this->assertSame('316912650057057350374175801344', (string) $b);
- }
+ $this->assertSame('316912650057057350374175801344', (string) $a);
+ $this->assertSame('316912650057057350374175801344', (string) $b);
+ }
- public function testDivide()
- {
- $x = $this->getInstance('1180591620717411303425'); // 2**70 + 1
- $y = $this->getInstance('12345678910');
+ public function testDivide()
+ {
+ $x = $this->getInstance('1180591620717411303425'); // 2**70 + 1
+ $y = $this->getInstance('12345678910');
- list($q, $r) = $x->divide($y);
+ list($q, $r) = $x->divide($y);
- $this->assertSame('95627922070', (string) $q);
- $this->assertSame('10688759725', (string) $r);
- }
+ $this->assertSame('95627922070', (string) $q);
+ $this->assertSame('10688759725', (string) $r);
+ }
- public function testModPow()
- {
- $a = $this->getInstance('10');
- $b = $this->getInstance('20');
- $c = $this->getInstance('30');
- $d = $a->modPow($b, $c);
+ public function testModPow()
+ {
+ $a = $this->getInstance('10');
+ $b = $this->getInstance('20');
+ $c = $this->getInstance('30');
+ $d = $a->modPow($b, $c);
- $this->assertSame('10', (string) $d);
- }
+ $this->assertSame('10', (string) $d);
+ }
- public function testModInverse()
- {
- $a = $this->getInstance(30);
- $b = $this->getInstance(17);
+ public function testModInverse()
+ {
+ $a = $this->getInstance(30);
+ $b = $this->getInstance(17);
- $c = $a->modInverse($b);
- $this->assertSame('4', (string) $c);
+ $c = $a->modInverse($b);
+ $this->assertSame('4', (string) $c);
- $d = $a->multiply($c);
- list($q, $r) = $d->divide($b);
- $this->assertSame('1', (string) $r);
- }
+ $d = $a->multiply($c);
+ list($q, $r) = $d->divide($b);
+ $this->assertSame('1', (string) $r);
+ }
- public function testExtendedGCD()
- {
- $a = $this->getInstance(693);
- $b = $this->getInstance(609);
+ public function testExtendedGCD()
+ {
+ $a = $this->getInstance(693);
+ $b = $this->getInstance(609);
- $arr = $a->extendedGCD($b);
+ $arr = $a->extendedGCD($b);
- $this->assertSame('21', (string) $arr['gcd']);
- $this->assertSame(21, $a->toString() * $arr['x']->toString() + $b->toString() * $arr['y']->toString());
- }
+ $this->assertSame('21', (string) $arr['gcd']);
+ $this->assertSame(21, $a->toString() * $arr['x']->toString() + $b->toString() * $arr['y']->toString());
+ }
- public function testGCD()
- {
- $x = $this->getInstance(693);
- $y = $this->getInstance(609);
- $this->assertSame('21', (string) $x->gcd($y));
- }
+ public function testGCD()
+ {
+ $x = $this->getInstance(693);
+ $y = $this->getInstance(609);
+ $this->assertSame('21', (string) $x->gcd($y));
+ }
- public function testAbs()
- {
- $x = $this->getInstance('-18446744073709551617');
- $y = $x->abs();
+ public function testAbs()
+ {
+ $x = $this->getInstance('-18446744073709551617');
+ $y = $x->abs();
- $this->assertSame('-18446744073709551617', (string) $x);
- $this->assertSame('18446744073709551617', (string) $y);
- }
+ $this->assertSame('-18446744073709551617', (string) $x);
+ $this->assertSame('18446744073709551617', (string) $y);
+ }
- public function testEquals()
- {
- $x = $this->getInstance('18446744073709551616');
- $y = $this->getInstance('18446744073709551616');
+ public function testEquals()
+ {
+ $x = $this->getInstance('18446744073709551616');
+ $y = $this->getInstance('18446744073709551616');
- $this->assertTrue($x->equals($y));
- $this->assertTrue($y->equals($x));
- }
+ $this->assertTrue($x->equals($y));
+ $this->assertTrue($y->equals($x));
+ }
- public function testCompare()
- {
- $a = $this->getInstance('-18446744073709551616');
- $b = $this->getInstance('36893488147419103232');
- $c = $this->getInstance('36893488147419103232');
- $d = $this->getInstance('316912650057057350374175801344');
+ public function testCompare()
+ {
+ $a = $this->getInstance('-18446744073709551616');
+ $b = $this->getInstance('36893488147419103232');
+ $c = $this->getInstance('36893488147419103232');
+ $d = $this->getInstance('316912650057057350374175801344');
- // a < b
- $this->assertLessThan(0, $a->compare($b));
- $this->assertGreaterThan(0, $b->compare($a));
+ // a < b
+ $this->assertLessThan(0, $a->compare($b));
+ $this->assertGreaterThan(0, $b->compare($a));
- // b = c
- $this->assertSame(0, $b->compare($c));
- $this->assertSame(0, $c->compare($b));
+ // b = c
+ $this->assertSame(0, $b->compare($c));
+ $this->assertSame(0, $c->compare($b));
- // c < d
- $this->assertLessThan(0, $c->compare($d));
- $this->assertGreaterThan(0, $d->compare($c));
- }
+ // c < d
+ $this->assertLessThan(0, $c->compare($d));
+ $this->assertGreaterThan(0, $d->compare($c));
+ }
- public function testBitwiseAND()
- {
- $x = $this->getInstance('66666666666666666666666', 16);
- $y = $this->getInstance('33333333333333333333333', 16);
- $z = $this->getInstance('22222222222222222222222', 16);
+ public function testBitwiseAND()
+ {
+ $x = $this->getInstance('66666666666666666666666', 16);
+ $y = $this->getInstance('33333333333333333333333', 16);
+ $z = $this->getInstance('22222222222222222222222', 16);
- $this->assertSame($z->toHex(), $x->bitwise_AND($y)->toHex());
- }
+ $this->assertSame($z->toHex(), $x->bitwise_AND($y)->toHex());
+ }
- public function testBitwiseOR()
- {
- $x = $this->getInstance('11111111111111111111111', 16);
- $y = $this->getInstance('EEEEEEEEEEEEEEEEEEEEEEE', 16);
- $z = $this->getInstance('FFFFFFFFFFFFFFFFFFFFFFF', 16);
+ public function testBitwiseOR()
+ {
+ $x = $this->getInstance('11111111111111111111111', 16);
+ $y = $this->getInstance('EEEEEEEEEEEEEEEEEEEEEEE', 16);
+ $z = $this->getInstance('FFFFFFFFFFFFFFFFFFFFFFF', 16);
- $this->assertSame($z->toHex(), $x->bitwise_OR($y)->toHex());
- }
+ $this->assertSame($z->toHex(), $x->bitwise_OR($y)->toHex());
+ }
- public function testBitwiseXOR()
- {
- $x = $this->getInstance('AFAFAFAFAFAFAFAFAFAFAFAF', 16);
- $y = $this->getInstance('133713371337133713371337', 16);
- $z = $this->getInstance('BC98BC98BC98BC98BC98BC98', 16);
+ public function testBitwiseXOR()
+ {
+ $x = $this->getInstance('AFAFAFAFAFAFAFAFAFAFAFAF', 16);
+ $y = $this->getInstance('133713371337133713371337', 16);
+ $z = $this->getInstance('BC98BC98BC98BC98BC98BC98', 16);
- $this->assertSame($z->toHex(), $x->bitwise_XOR($y)->toHex());
- }
+ $this->assertSame($z->toHex(), $x->bitwise_XOR($y)->toHex());
+ }
- public function testBitwiseNOT()
- {
- $x = $this->getInstance('EEEEEEEEEEEEEEEEEEEEEEE', 16);
- $z = $this->getInstance('11111111111111111111111', 16);
+ public function testBitwiseNOT()
+ {
+ $x = $this->getInstance('EEEEEEEEEEEEEEEEEEEEEEE', 16);
+ $z = $this->getInstance('11111111111111111111111', 16);
- $this->assertSame($z->toHex(), $x->bitwise_NOT()->toHex());
- }
+ $this->assertSame($z->toHex(), $x->bitwise_NOT()->toHex());
+ }
- public function testBitwiseLeftShift()
- {
- $x = $this->getInstance('0x0000000FF0000000', 16);
- $y = $this->getInstance('0x000FF00000000000', 16);
+ public function testBitwiseLeftShift()
+ {
+ $x = $this->getInstance('0x0000000FF0000000', 16);
+ $y = $this->getInstance('0x000FF00000000000', 16);
- $this->assertSame($y->toHex(), $x->bitwise_LeftShift(16)->toHex());
- }
+ $this->assertSame($y->toHex(), $x->bitwise_LeftShift(16)->toHex());
+ }
- public function testBitwiseRightShift()
- {
- $x = $this->getInstance('0x0000000FF0000000', 16);
- $y = $this->getInstance('0x00000000000FF000', 16);
- $z = $this->getInstance('0x000000000000000F', 16);
- $n = $this->getInstance(0);
+ public function testBitwiseRightShift()
+ {
+ $x = $this->getInstance('0x0000000FF0000000', 16);
+ $y = $this->getInstance('0x00000000000FF000', 16);
+ $z = $this->getInstance('0x000000000000000F', 16);
+ $n = $this->getInstance(0);
- $this->assertSame($y->toHex(), $x->bitwise_RightShift(16)->toHex());
- $this->assertSame($z->toHex(), $x->bitwise_RightShift(32)->toHex());
- $this->assertSame($n->toHex(), $x->bitwise_RightShift(36)->toHex());
- }
+ $this->assertSame($y->toHex(), $x->bitwise_RightShift(16)->toHex());
+ $this->assertSame($z->toHex(), $x->bitwise_RightShift(32)->toHex());
+ $this->assertSame($n->toHex(), $x->bitwise_RightShift(36)->toHex());
+ }
- public function testSerializable()
- {
- $x = $this->getInstance('18446744073709551616');
- $y = unserialize(serialize($x));
+ public function testSerializable()
+ {
+ $x = $this->getInstance('18446744073709551616');
+ $y = unserialize(serialize($x));
- $this->assertTrue($x->equals($y));
- $this->assertTrue($y->equals($x));
+ $this->assertTrue($x->equals($y));
+ $this->assertTrue($y->equals($x));
- $this->assertSame('18446744073709551616', (string) $x);
- $this->assertSame('18446744073709551616', (string) $y);
- }
+ $this->assertSame('18446744073709551616', (string) $x);
+ $this->assertSame('18446744073709551616', (string) $y);
+ }
- public function testClone()
- {
- $x = $this->getInstance('18446744073709551616');
- $y = clone $x;
+ public function testClone()
+ {
+ $x = $this->getInstance('18446744073709551616');
+ $y = clone $x;
- $this->assertTrue($x->equals($y));
- $this->assertTrue($y->equals($x));
+ $this->assertTrue($x->equals($y));
+ $this->assertTrue($y->equals($x));
- $this->assertSame('18446744073709551616', (string) $x);
- $this->assertSame('18446744073709551616', (string) $y);
- }
+ $this->assertSame('18446744073709551616', (string) $x);
+ $this->assertSame('18446744073709551616', (string) $y);
+ }
}
diff --git a/tests/Net/SSH1Test.php b/tests/Net/SSH1Test.php
index dc02c36d..7c58ceb3 100644
--- a/tests/Net/SSH1Test.php
+++ b/tests/Net/SSH1Test.php
@@ -1,8 +1,8 @@
- * @copyright MMXIII Marc Scholten
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @author Marc Scholten
+ * @copyright MMXIII Marc Scholten
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
class Net_SSH1Test extends PhpseclibTestCase
diff --git a/tests/Net/SSH2Test.php b/tests/Net/SSH2Test.php
index 1f0eca9f..a6f0f9b7 100644
--- a/tests/Net/SSH2Test.php
+++ b/tests/Net/SSH2Test.php
@@ -1,24 +1,13 @@
- * @copyright MMXIII Marc Scholten
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @author Marc Scholten
+ * @copyright MMXIII Marc Scholten
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
class Net_SSH2Test extends PhpseclibTestCase
{
- /**
- * @return Net_SSH2
- */
- private function createSSHMock()
- {
- return $this->getMockBuilder('Net_SSH2')
- ->disableOriginalConstructor()
- ->setMethods(array('__destruct'))
- ->getMock();
- }
-
public function formatLogDataProvider()
{
return array(
@@ -65,12 +54,12 @@ class Net_SSH2Test extends PhpseclibTestCase
public function testGenerateIdentifier($expected, array $requiredExtensions)
{
$notAllowed = array('gmp', 'bcmath', 'mcrypt', 'gmp');
- foreach($notAllowed as $notAllowedExtension) {
- if(in_array($notAllowedExtension, $requiredExtensions)) {
+ foreach ($notAllowed as $notAllowedExtension) {
+ if (in_array($notAllowedExtension, $requiredExtensions)) {
continue;
}
- if(extension_loaded($notAllowedExtension)) {
+ if (extension_loaded($notAllowedExtension)) {
$this->markTestSkipped('Extension ' . $notAllowedExtension . ' is not allowed for this data-set');
}
}
@@ -81,4 +70,14 @@ class Net_SSH2Test extends PhpseclibTestCase
$this->assertEquals($expected, $identifier);
}
+ /**
+ * @return Net_SSH2
+ */
+ protected function createSSHMock()
+ {
+ return $this->getMockBuilder('Net_SSH2')
+ ->disableOriginalConstructor()
+ ->setMethods(array('__destruct'))
+ ->getMock();
+ }
}
diff --git a/tests/PhpseclibTestCase.php b/tests/PhpseclibTestCase.php
index 22cdb95e..3369ad16 100644
--- a/tests/PhpseclibTestCase.php
+++ b/tests/PhpseclibTestCase.php
@@ -1,74 +1,64 @@
- * @copyright MMXIII Andreas Fischer
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @author Andreas Fischer
+ * @copyright MMXIII Andreas Fischer
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
abstract class PhpseclibTestCase extends PHPUnit_Framework_TestCase
{
- /**
- * @param string $constant
- * @param mixed $expected
- *
- * @return null
- */
- static protected function ensureConstant($constant, $expected)
- {
- if (defined($constant))
- {
- $value = constant($constant);
+ /**
+ * @param string $constant
+ * @param mixed $expected
+ *
+ * @return null
+ */
+ static protected function ensureConstant($constant, $expected)
+ {
+ if (defined($constant)) {
+ $value = constant($constant);
- if ($value !== $expected)
- {
- if (function_exists('runkit_constant_redefine'))
- {
- if (!runkit_constant_redefine($constant, $expected))
- {
- self::markTestSkipped(sprintf(
- "Failed to redefine constant %s to %s",
- $constant,
- $expected
- ));
- }
- }
- else
- {
- self::markTestSkipped(sprintf(
- "Skipping test because constant %s is %s instead of %s",
- $constant,
- $value,
- $expected
- ));
- }
- }
- }
- else
- {
- define($constant, $expected);
- }
- }
+ if ($value !== $expected) {
+ if (function_exists('runkit_constant_redefine')) {
+ if (!runkit_constant_redefine($constant, $expected)) {
+ self::markTestSkipped(sprintf(
+ "Failed to redefine constant %s to %s",
+ $constant,
+ $expected
+ ));
+ }
+ } else {
+ self::markTestSkipped(sprintf(
+ "Skipping test because constant %s is %s instead of %s",
+ $constant,
+ $value,
+ $expected
+ ));
+ }
+ }
+ } else {
+ define($constant, $expected);
+ }
+ }
- /**
- * @param string $filename
- *
- * @return null
- */
- static protected function reRequireFile($filename)
- {
- if (function_exists('runkit_import'))
- {
- $result = runkit_import(
- $filename,
- RUNKIT_IMPORT_FUNCTIONS |
- RUNKIT_IMPORT_CLASS_METHODS |
- RUNKIT_IMPORT_OVERRIDE
- );
+ /**
+ * @param string $filename
+ *
+ * @return null
+ */
+ static protected function reRequireFile($filename)
+ {
+ if (function_exists('runkit_import')) {
+ $result = runkit_import(
+ $filename,
+ RUNKIT_IMPORT_FUNCTIONS |
+ RUNKIT_IMPORT_CLASS_METHODS |
+ RUNKIT_IMPORT_OVERRIDE
+ );
- if (!$result)
- {
- self::markTestSkipped("Failed to reimport file $filename");
- }
- }
- }
+ if (!$result) {
+ self::markTestSkipped("Failed to reimport file $filename");
+ }
+ }
+ }
}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 7db5b570..cb9fc617 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -2,7 +2,7 @@
/**
* Bootstrapping File for phpseclib Test Suite
*
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
date_default_timezone_set('UTC');
@@ -10,35 +10,34 @@ date_default_timezone_set('UTC');
// Set up include path accordingly. This is especially required because some
// class files of phpseclib require() other dependencies.
set_include_path(implode(PATH_SEPARATOR, array(
- dirname(__FILE__) . '/../phpseclib/',
- dirname(__FILE__) . '/',
- get_include_path(),
+ dirname(__FILE__) . '/../phpseclib/',
+ dirname(__FILE__) . '/',
+ get_include_path(),
)));
function phpseclib_is_includable($suffix)
{
- foreach (explode(PATH_SEPARATOR, get_include_path()) as $prefix)
- {
- $ds = substr($prefix, -1) == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR;
- $file = $prefix . $ds . $suffix;
+ foreach (explode(PATH_SEPARATOR, get_include_path()) as $prefix) {
+ $ds = substr($prefix, -1) == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR;
+ $file = $prefix . $ds . $suffix;
- if (file_exists($file))
- {
- return true;
- }
- }
+ if (file_exists($file)) {
+ return true;
+ }
+ }
- return false;
+ return false;
}
function phpseclib_autoload($class)
{
- $file = str_replace('_', '/', $class) . '.php';
+ $file = str_replace('_', '/', $class) . '.php';
- if (phpseclib_is_includable($file))
- {
- require $file;
- }
+ if (phpseclib_is_includable($file)) {
+ // @codingStandardsIgnoreStart
+ require $file;
+ // @codingStandardsIgnoreEnd
+ }
}
spl_autoload_register('phpseclib_autoload');
diff --git a/tests/code_sniffer_ruleset.xml b/tests/code_sniffer_ruleset.xml
deleted file mode 100644
index 91af1a2a..00000000
--- a/tests/code_sniffer_ruleset.xml
+++ /dev/null
@@ -1,77 +0,0 @@
-
-
-
- phpseclib coding standard
-
-
-
-
-
-
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-