Skip to content

Commit 52af863

Browse files
committed
revert changes to unit tests
1 parent 50affd7 commit 52af863

File tree

2 files changed

+44
-137
lines changed

2 files changed

+44
-137
lines changed

phpunit.xml.dist

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.1/phpunit.xsd"
5-
backupGlobals="false"
6-
colors="true"
7-
bootstrap="vendor/autoload.php"
8-
cacheDirectory=".phpunit.cache"
9-
>
10-
<testsuites>
11-
<testsuite name="phpseclib Unit Test Suite">
12-
<directory>tests/</directory>
13-
</testsuite>
14-
</testsuites>
15-
<source>
16-
<include>
17-
<directory>lib/</directory>
18-
</include>
19-
</source>
20-
</phpunit>
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
5+
backupGlobals="false"
6+
colors="true"
7+
bootstrap="vendor/autoload.php"
8+
>
9+
<testsuites>
10+
<testsuite name="phpseclib Unit Test Suite">
11+
<directory>tests/</directory>
12+
</testsuite>
13+
</testsuites>
14+
15+
<filter>
16+
<whitelist>
17+
<directory>lib/</directory>
18+
</whitelist>
19+
</filter>
20+
</phpunit>

tests/BCMathTest.php

+26-119
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
1-
<?php //declare(strict_types=1);
1+
<?php
22

33
use bcmath_compat\BCMath;
44

5-
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
6-
use PHPUnit\Framework\Attributes\RequiresPhp;
7-
use PHPUnit\Framework\Attributes\DataProvider;
8-
use PHPUnit\Framework\TestCase;
9-
// use PHPUnit\Framework\Attributes\TestWith;
10-
115
/**
12-
* requires extension bcmath
6+
* @requires extension bcmath
137
*/
14-
#[RequiresPhpExtension('bcmath')]
15-
class BCMathTest extends TestCase
8+
class BCMathTest extends PHPUnit\Framework\TestCase
169
{
17-
static $emsg = '';
1810
/**
1911
* Produces all combinations of test values.
2012
*
2113
* @return array
2214
*/
23-
public static function generateTwoParams()
15+
public function generateTwoParams()
2416
{
2517
$r = [
2618
['9', '9'],
@@ -53,7 +45,9 @@ public static function generateTwoParams()
5345
return $r;
5446
}
5547

56-
#[DataProvider('generateTwoParams')]
48+
/**
49+
* @dataProvider generateTwoParams
50+
*/
5751
public function testAdd(...$params)
5852
{
5953
$a = bcadd(...$params);
@@ -66,7 +60,9 @@ public function testAdd(...$params)
6660
$this->assertSame($a, $b);
6761
}
6862

69-
#[DataProvider('generateTwoParams')]
63+
/**
64+
* @dataProvider generateTwoParams
65+
*/
7066
public function testSub(...$params)
7167
{
7268
$a = bcsub(...$params);
@@ -80,11 +76,9 @@ public function testSub(...$params)
8076
}
8177

8278
/**
83-
* requires PHP 7.3
79+
* @dataProvider generateTwoParams
80+
* @requires PHP 7.3
8481
*/
85-
86-
#[RequiresPhp('>7.3')]
87-
#[DataProvider('generateTwoParams')]
8882
public function testMul(...$params)
8983
{
9084
$a = bcmul(...$params);
@@ -97,7 +91,9 @@ public function testMul(...$params)
9791
$this->assertSame($a, $b);
9892
}
9993

100-
#[DataProvider('generateTwoParams')]
94+
/**
95+
* @dataProvider generateTwoParams
96+
*/
10197
public function testDiv(...$params)
10298
{
10399
if ($params[1] === '0' || $params[1] === '-0') {
@@ -114,12 +110,9 @@ public function testDiv(...$params)
114110
}
115111

116112
/**
117-
* dataProvider generateTwoParams
118-
* requires PHP 7.2
113+
* @dataProvider generateTwoParams
114+
* @requires PHP 7.2
119115
*/
120-
121-
#[DataProvider('generateTwoParams')]
122-
#[RequiresPhp('>7.2')]
123116
public function testMod(...$params)
124117
{
125118
if ($params[1] === '0' || $params[1] === '-0') {
@@ -140,7 +133,7 @@ public function testMod(...$params)
140133
*
141134
* @return array
142135
*/
143-
public static function generatePowParams()
136+
public function generatePowParams()
144137
{
145138
return [
146139
['9', '9'],
@@ -161,10 +154,8 @@ public static function generatePowParams()
161154

162155
/**
163156
* @dataProvider generatePowParams
164-
* requires PHP 7.3
157+
* @requires PHP 7.3
165158
*/
166-
#[DataProvider('generatePowParams')]
167-
#[RequiresPhp('>7.3')]
168159
public function testPow(...$params)
169160
{
170161
$a = bcpow(...$params);
@@ -177,7 +168,7 @@ public function testPow(...$params)
177168
*
178169
* @return array
179170
*/
180-
public static function generatePowModParams()
171+
public function generatePowModParams()
181172
{
182173
return [
183174
['9', '9', '17'],
@@ -197,13 +188,10 @@ public static function generatePowModParams()
197188
}
198189

199190
/**
200-
* dataProvider generatePowModParams
201-
* requires PHP 7.3
191+
* @dataProvider generatePowModParams
192+
* @requires PHP 7.3
202193
*/
203-
#[DataProvider('generatePowModParams')]
204-
#[RequiresPhp('>7.3')]
205-
206-
public function testPowMod(...$params)
194+
public function testPowMod(...$params)
207195
{
208196
$a = bcpowmod(...$params);
209197
$b = BCMath::powmod(...$params);
@@ -227,19 +215,9 @@ public function testSqrt()
227215

228216
public function testBoolScale()
229217
{
230-
if(false) {
231-
$exception_thrown = false;
232-
try {
233-
$a = bcadd('5', '2', false);
234-
} catch (TypeError $e) {
235-
$exception_thrown = true;
236-
}
237-
$this->assertSame(true, $exception_thrown);
238-
} else {
239-
$a = bcadd('5','2', false);
240-
$b = BCMath::add('5', '2', false);
241-
$this->assertSame($a, $b);
242-
}
218+
$a = bcadd('5', '2', false);
219+
$b = BCMath::add('5', '2', false);
220+
$this->assertSame($a, $b);
243221
}
244222

245223
public function testIntParam()
@@ -268,75 +246,4 @@ public function setExpectedException($name, $message = null, $code = null)
268246
$this->expectExceptionCode($code);
269247
}
270248
}
271-
272-
public static function generateScaleCallstaticParams()
273-
{
274-
return [
275-
[4],
276-
[4,2],
277-
[4,2,3],
278-
[4,2,3,5],
279-
];
280-
}
281-
282-
#[DataProvider('generateScaleCallstaticParams')]
283-
public function test_argumentsScaleCallstatic(...$params)
284-
{
285-
//scale with 1, 2, 3 parameters
286-
if (func_num_args() == 1) {
287-
bcscale(...$params);
288-
BCMath::scale(...$params);
289-
$scale = bcscale();
290-
$orig = $params[0];
291-
$this->assertSame($orig,$scale);
292-
$scale = BCMath::scale();
293-
$this->assertSame($orig,$scale);
294-
} else {
295-
$exception_thrown = false;
296-
try{
297-
BCMath::scale(...$params);
298-
} catch (ArgumentCountError $e) {
299-
$exception_thrown = true;
300-
}
301-
$this->assertSame(true, $exception_thrown);
302-
if (true) {
303-
// start the unit test with: (showing the wrong given values)
304-
// phpunit --testdox-test testdox.txt --display-skipped
305-
$this->markTestSkipped('ArgumentCountError in ' . $e->getFile() . ':' . $e->getLine() . ' : ' . $e->getMessage());
306-
}
307-
}
308-
}
309-
public static function generatePowModCallstaticParams()
310-
{
311-
return [
312-
['9'],
313-
['9', '17'],
314-
['9', '17', '-111'],
315-
['9', '17', '-111', 5],
316-
['9', '17', '-111', 5, 8],
317-
];
318-
}
319-
#[DataProvider('generatePowModCallstaticParams')]
320-
public function test_argumentsPowModCallstatic(...$params)
321-
{
322-
//scale with 1, 2, 3 parameters
323-
if (func_num_args() > 2 && func_num_args() < 5) {
324-
$a = bcpowmod(...$params);
325-
$b = BCMath::powmod(...$params);
326-
$this->assertSame($a,$b);
327-
} else {
328-
$exception_thrown = false;
329-
try{
330-
BCMath::powmod(...$params);
331-
} catch (ArgumentCountError $e) {
332-
$exception_thrown = true;
333-
}
334-
$this->assertSame(true, $exception_thrown);
335-
if (true) {
336-
// start the unit test with: (showing the wrong given values)
337-
// phpunit --testdox-test testdox.txt --display-skipped
338-
$this->markTestSkipped('ArgumentCountError in ' . $e->getFile() . ':' . $e->getLine() . ' : ' . $e->getMessage());
339-
}
340-
}
341-
}
342249
}

0 commit comments

Comments
 (0)