Skip to content

Commit e5523e0

Browse files
fix conversions test structure
1 parent a305f06 commit e5523e0

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

Diff for: tests/Conversions/ConversionsTest.php

+22-24
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
use function PHPUnit\Framework\assertEquals;
4-
53
use PHPUnit\Framework\TestCase;
64

75
require_once __DIR__ . '/../../vendor/autoload.php';
@@ -16,70 +14,70 @@ class ConversionsTest extends TestCase
1614
{
1715
public function testBinaryToDecimal()
1816
{
19-
assertEquals(binaryToDecimal(111), 7);
20-
assertEquals(binaryToDecimal(101), 5);
17+
$this->assertEquals(7, binaryToDecimal(111));
18+
$this->assertEquals(5, binaryToDecimal(101));
2119
$this->expectException(\Exception::class);
2220
$this->expectExceptionMessage('Please pass a valid Binary Number for Converting it to a Decimal Number.');
2321
binaryToDecimal("this is a string");
2422
}
2523

2624
public function testDecimalToBinary()
2725
{
28-
assertEquals(decimalToBinary(7), 111);
29-
assertEquals(decimalToBinary(5), 101);
26+
$this->assertEquals(111, decimalToBinary(7));
27+
$this->assertEquals(101, decimalToBinary(5));
3028
$this->expectException(\Exception::class);
3129
$this->expectExceptionMessage('Please pass a valid Decimal Number for Converting it to a Binary Number.');
3230
decimalToBinary("this is a string");
3331
}
3432

3533
public function testOctalToDecimal()
3634
{
37-
assertEquals(octalToDecimal(10), 8);
38-
assertEquals(octalToDecimal(11), 9);
39-
assertEquals(octalToDecimal(1115), 589);
35+
$this->assertEquals(8, octalToDecimal(10));
36+
$this->assertEquals(9, octalToDecimal(11));
37+
$this->assertEquals(589, octalToDecimal(1115));
4038
$this->expectException(\Exception::class);
4139
$this->expectExceptionMessage('Please pass a valid Octal Number for Converting it to a Decimal Number.');
4240
octalToDecimal("this is a string");
4341
}
4442

4543
public function testDecimalToOctal()
4644
{
47-
assertEquals(decimalToOctal(8), 10);
48-
assertEquals(decimalToOctal(9), 11);
49-
assertEquals(decimalToOctal(589), 1115);
45+
$this->assertEquals(10, decimalToOctal(8));
46+
$this->assertEquals(11, decimalToOctal(9));
47+
$this->assertEquals(1115, decimalToOctal(589));
5048
$this->expectException(\Exception::class);
5149
$this->expectExceptionMessage('Please pass a valid Decimal Number for Converting it to an Octal Number.');
5250
decimalToOctal("this is a string");
5351
}
5452

5553
public function testDecimalToHex()
5654
{
57-
assertEquals(decimalToHex(10), 'A');
58-
assertEquals(decimalToHex(489201875), '1D28A0D3');
59-
assertEquals(decimalToHex(171), 'AB');
55+
$this->assertEquals('A', decimalToHex(10));
56+
$this->assertEquals('1D28A0D3', decimalToHex(489201875));
57+
$this->assertEquals('AB', decimalToHex(171));
6058
$this->expectException(\Exception::class);
6159
$this->expectExceptionMessage('Please pass a valid Decimal Number for Converting it to a Hexadecimal Number.');
6260
decimalToHex("this is a string");
6361
}
6462

6563
public function testHexToDecimal()
6664
{
67-
assertEquals(hexToDecimal('A'), 10);
68-
assertEquals(hexToDecimal('1D28A0D3'), 489201875);
69-
assertEquals(hexToDecimal('AB'), 171);
65+
$this->assertEquals(10, hexToDecimal('A'));
66+
$this->assertEquals(489201875, hexToDecimal('1D28A0D3'));
67+
$this->assertEquals(171, hexToDecimal('AB'));
7068
$this->expectException(\Exception::class);
7169
$this->expectExceptionMessage('Please pass a valid Hexadecimal Number for Converting it to a Decimal Number.');
7270
hexToDecimal("this is a string");
7371
}
7472

7573
public function testSpeedConversion()
7674
{
77-
assertEquals(convertSpeed(5, 'm/s', 'mph'), 11.18);
78-
assertEquals(convertSpeed(5, 'ft/s', 'km/h'), 5.49);
79-
assertEquals(convertSpeed(3, 'km/h', 'km/h'), 3);
80-
assertEquals(convertSpeed(7, 'kn', 'km/h'), 12.96);
81-
assertEquals(convertSpeed(12, 'mph', 'km/h'), 19.31);
82-
assertEquals(convertSpeed(0.514, 'm/s', 'kn'), 1);
75+
$this->assertEquals(11.18, convertSpeed(5, 'm/s', 'mph'));
76+
$this->assertEquals(5.49, convertSpeed(5, 'ft/s', 'km/h'));
77+
$this->assertEquals(3, convertSpeed(3, 'km/h', 'km/h'));
78+
$this->assertEquals(12.96, convertSpeed(7, 'kn', 'km/h'));
79+
$this->assertEquals(19.31, convertSpeed(12, 'mph', 'km/h'));
80+
$this->assertEquals(1, convertSpeed(0.514, 'm/s', 'kn'));
8381

8482
$this->expectException(\Exception::class);
8583
convertSpeed('1', 'km/h', 'mph');

0 commit comments

Comments
 (0)