mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-16 10:15:14 +00:00
Tests: data providers need to be static
This commit is contained in:
parent
b0c0a82ae7
commit
89f0d3c952
@ -30,7 +30,7 @@ abstract class TestCase extends PhpseclibTestCase
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function continuousBufferCombos()
|
public static function continuousBufferCombos()
|
||||||
{
|
{
|
||||||
$modes = [
|
$modes = [
|
||||||
'ctr',
|
'ctr',
|
||||||
@ -133,7 +133,7 @@ abstract class TestCase extends PhpseclibTestCase
|
|||||||
*
|
*
|
||||||
* @return list<array{string, string, array}>
|
* @return list<array{string, string, array}>
|
||||||
*/
|
*/
|
||||||
public function continuousBufferBatteryCombos()
|
public static function continuousBufferBatteryCombos()
|
||||||
{
|
{
|
||||||
$modes = [
|
$modes = [
|
||||||
'ctr',
|
'ctr',
|
||||||
@ -176,9 +176,9 @@ abstract class TestCase extends PhpseclibTestCase
|
|||||||
/**
|
/**
|
||||||
* @return array<array{string, string, array}>
|
* @return array<array{string, string, array}>
|
||||||
*/
|
*/
|
||||||
public function continuousBufferBatteryCombosWithoutSingleCombos()
|
public static function continuousBufferBatteryCombosWithoutSingleCombos()
|
||||||
{
|
{
|
||||||
return array_filter($this->continuousBufferBatteryCombos(), function (array $continuousBufferBatteryCombo) {
|
return array_filter(self::continuousBufferBatteryCombos(), function (array $continuousBufferBatteryCombo) {
|
||||||
return count($continuousBufferBatteryCombo[2]) > 1;
|
return count($continuousBufferBatteryCombo[2]) > 1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ use phpseclib3\Tests\PhpseclibTestCase;
|
|||||||
|
|
||||||
class BlowfishTest extends PhpseclibTestCase
|
class BlowfishTest extends PhpseclibTestCase
|
||||||
{
|
{
|
||||||
public function engineVectors()
|
public static function engineVectors()
|
||||||
{
|
{
|
||||||
$engines = [
|
$engines = [
|
||||||
'PHP',
|
'PHP',
|
||||||
|
@ -16,7 +16,7 @@ use phpseclib3\Tests\PhpseclibTestCase;
|
|||||||
|
|
||||||
class CurveTest extends PhpseclibTestCase
|
class CurveTest extends PhpseclibTestCase
|
||||||
{
|
{
|
||||||
public function curves()
|
public static function curves()
|
||||||
{
|
{
|
||||||
$curves = [];
|
$curves = [];
|
||||||
foreach (new \DirectoryIterator(__DIR__ . '/../../../../phpseclib/Crypt/EC/Curves/') as $file) {
|
foreach (new \DirectoryIterator(__DIR__ . '/../../../../phpseclib/Crypt/EC/Curves/') as $file) {
|
||||||
@ -38,7 +38,7 @@ class CurveTest extends PhpseclibTestCase
|
|||||||
return $curves;
|
return $curves;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function allCurves()
|
public static function allCurves()
|
||||||
{
|
{
|
||||||
$curves = [];
|
$curves = [];
|
||||||
foreach (new \DirectoryIterator(__DIR__ . '/../../../../phpseclib/Crypt/EC/Curves/') as $file) {
|
foreach (new \DirectoryIterator(__DIR__ . '/../../../../phpseclib/Crypt/EC/Curves/') as $file) {
|
||||||
@ -55,7 +55,7 @@ class CurveTest extends PhpseclibTestCase
|
|||||||
return $curves;
|
return $curves;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function curvesWithOIDs()
|
public static function curvesWithOIDs()
|
||||||
{
|
{
|
||||||
$class = new \ReflectionClass('phpseclib3\Crypt\EC\Formats\Keys\PKCS8');
|
$class = new \ReflectionClass('phpseclib3\Crypt\EC\Formats\Keys\PKCS8');
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ class GCMTest extends PhpseclibTestCase
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function engine128Vectors()
|
public static function engine128Vectors()
|
||||||
{
|
{
|
||||||
$engines = [
|
$engines = [
|
||||||
'PHP',
|
'PHP',
|
||||||
@ -131,7 +131,7 @@ class GCMTest extends PhpseclibTestCase
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function engine256Vectors()
|
public static function engine256Vectors()
|
||||||
{
|
{
|
||||||
$engines = [
|
$engines = [
|
||||||
'PHP',
|
'PHP',
|
||||||
|
@ -426,7 +426,7 @@ class HashTest extends PhpseclibTestCase
|
|||||||
$this->assertSame($hash->getLengthInBytes(), $length);
|
$this->assertSame($hash->getLengthInBytes(), $length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function lengths()
|
public static function lengths()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// known
|
// known
|
||||||
@ -439,7 +439,7 @@ class HashTest extends PhpseclibTestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function UMACs()
|
public static function UMACs()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['', 'umac-32', '113145FB', "umac-32 and message of <empty>"],
|
['', 'umac-32', '113145FB', "umac-32 and message of <empty>"],
|
||||||
|
@ -13,14 +13,14 @@ use phpseclib3\Tests\PhpseclibTestCase;
|
|||||||
|
|
||||||
class RC2Test extends PhpseclibTestCase
|
class RC2Test extends PhpseclibTestCase
|
||||||
{
|
{
|
||||||
public $engines = [
|
public static $engines = [
|
||||||
'PHP',
|
'PHP',
|
||||||
'Eval',
|
'Eval',
|
||||||
'mcrypt',
|
'mcrypt',
|
||||||
'OpenSSL',
|
'OpenSSL',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function engineVectors()
|
public static function engineVectors()
|
||||||
{
|
{
|
||||||
// tests from https://tools.ietf.org/html/rfc2268#page-8
|
// tests from https://tools.ietf.org/html/rfc2268#page-8
|
||||||
$tests = [
|
$tests = [
|
||||||
@ -37,7 +37,7 @@ class RC2Test extends PhpseclibTestCase
|
|||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
foreach ($this->engines as $engine) {
|
foreach (self::$engines as $engine) {
|
||||||
foreach ($tests as $test) {
|
foreach ($tests as $test) {
|
||||||
$result[] = [$engine, $test[0], $test[1], $test[2], $test[3]];
|
$result[] = [$engine, $test[0], $test[1], $test[2], $test[3]];
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ use phpseclib3\Tests\PhpseclibTestCase;
|
|||||||
|
|
||||||
class RC4Test extends PhpseclibTestCase
|
class RC4Test extends PhpseclibTestCase
|
||||||
{
|
{
|
||||||
public function engineVectors()
|
public static function engineVectors()
|
||||||
{
|
{
|
||||||
$engines = [
|
$engines = [
|
||||||
'PHP',
|
'PHP',
|
||||||
|
@ -13,9 +13,9 @@ use phpseclib3\Tests\PhpseclibTestCase;
|
|||||||
|
|
||||||
class RandomTest extends PhpseclibTestCase
|
class RandomTest extends PhpseclibTestCase
|
||||||
{
|
{
|
||||||
public function stringLengthData()
|
public static function stringLengthData()
|
||||||
{
|
{
|
||||||
return array_map([$this, 'wrap'], [
|
return array_map(function($x) { return [$x]; }, [
|
||||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 17, 19, 20, 23, 29, 31, 37,
|
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 17, 19, 20, 23, 29, 31, 37,
|
||||||
41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 111, 128, 1000,
|
41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 111, 128, 1000,
|
||||||
1024, 10000, 12345, 100000, 123456
|
1024, 10000, 12345, 100000, 123456
|
||||||
@ -50,10 +50,4 @@ class RandomTest extends PhpseclibTestCase
|
|||||||
$values[$rand] = true;
|
$values[$rand] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function wrap($x)
|
|
||||||
{
|
|
||||||
// array() is not a function, but $this->wrap() is.
|
|
||||||
return [$x];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ use phpseclib3\Tests\PhpseclibTestCase;
|
|||||||
|
|
||||||
class Salsa20Test extends PhpseclibTestCase
|
class Salsa20Test extends PhpseclibTestCase
|
||||||
{
|
{
|
||||||
public function engineVectors()
|
public static function engineVectors()
|
||||||
{
|
{
|
||||||
$engines = [
|
$engines = [
|
||||||
'PHP',
|
'PHP',
|
||||||
|
@ -13,14 +13,14 @@ use phpseclib3\Tests\PhpseclibTestCase;
|
|||||||
|
|
||||||
class TripleDESTest extends PhpseclibTestCase
|
class TripleDESTest extends PhpseclibTestCase
|
||||||
{
|
{
|
||||||
public $engines = [
|
public static $engines = [
|
||||||
'PHP',
|
'PHP',
|
||||||
'Eval',
|
'Eval',
|
||||||
'mcrypt',
|
'mcrypt',
|
||||||
'OpenSSL',
|
'OpenSSL',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function engineVectors()
|
public static function engineVectors()
|
||||||
{
|
{
|
||||||
// tests from http://csrc.nist.gov/publications/nistpubs/800-20/800-20.pdf#page=273
|
// tests from http://csrc.nist.gov/publications/nistpubs/800-20/800-20.pdf#page=273
|
||||||
$tests = [
|
$tests = [
|
||||||
@ -94,7 +94,7 @@ class TripleDESTest extends PhpseclibTestCase
|
|||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
foreach ($this->engines as $engine) {
|
foreach (self::$engines as $engine) {
|
||||||
foreach ($tests as $test) {
|
foreach ($tests as $test) {
|
||||||
$result[] = [$engine, $test[0], $test[1], $test[2]];
|
$result[] = [$engine, $test[0], $test[1], $test[2]];
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ class TripleDESTest extends PhpseclibTestCase
|
|||||||
$this->assertEquals($result, $expected, "Failed asserting that $plaintext yielded expected output in $engine engine");
|
$this->assertEquals($result, $expected, "Failed asserting that $plaintext yielded expected output in $engine engine");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function engineIVVectors()
|
public static function engineIVVectors()
|
||||||
{
|
{
|
||||||
$engines = [
|
$engines = [
|
||||||
'PHP',
|
'PHP',
|
||||||
@ -184,7 +184,7 @@ class TripleDESTest extends PhpseclibTestCase
|
|||||||
$des->setKey('abcdefghijklmnopqrstuvwx');
|
$des->setKey('abcdefghijklmnopqrstuvwx');
|
||||||
$des->setIV(str_repeat("\0", $des->getBlockLength() >> 3));
|
$des->setIV(str_repeat("\0", $des->getBlockLength() >> 3));
|
||||||
|
|
||||||
foreach ($this->engines as $engine) {
|
foreach (self::$engines as $engine) {
|
||||||
$des->setPreferredEngine($engine);
|
$des->setPreferredEngine($engine);
|
||||||
if (!$des->isValidEngine($engine)) {
|
if (!$des->isValidEngine($engine)) {
|
||||||
self::markTestSkipped("Unable to initialize $engine engine");
|
self::markTestSkipped("Unable to initialize $engine engine");
|
||||||
@ -212,7 +212,7 @@ class TripleDESTest extends PhpseclibTestCase
|
|||||||
/**
|
/**
|
||||||
* @return list<array{string, string}>
|
* @return list<array{string, string}>
|
||||||
*/
|
*/
|
||||||
public function provideForCorrectSelfUseInLambda()
|
public static function provideForCorrectSelfUseInLambda()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['YWFhYWFhYWFhYWFhYWFhYWFhYWG9l9gm', 'fDSmC5bbLdx8NKYLltst3Hw0pguW2y3cfDSmC5bbLdxmhqEOIeS2ig=='],
|
['YWFhYWFhYWFhYWFhYWFhYWFhYWG9l9gm', 'fDSmC5bbLdx8NKYLltst3Hw0pguW2y3cfDSmC5bbLdxmhqEOIeS2ig=='],
|
||||||
|
@ -14,7 +14,7 @@ use phpseclib3\Tests\PhpseclibTestCase;
|
|||||||
|
|
||||||
class SSH2UnitTest extends PhpseclibTestCase
|
class SSH2UnitTest extends PhpseclibTestCase
|
||||||
{
|
{
|
||||||
public function formatLogDataProvider()
|
public static function formatLogDataProvider()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
|
Loading…
Reference in New Issue
Block a user