Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let assertEquals change into assertSame #25

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions test/unit/BitPayKeyUtils/KeyHelper/KeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testGetIdWhenIdSet()
$id = 'test';
$testedObject = $this->getTestedClass($id);
$result = $testedObject->getId();
$this->assertEquals($id, $result);
$this->assertSame($id, $result);
}

/**
Expand All @@ -37,7 +37,7 @@ public function testGetHex()

$this->setProtectedPropertyValue($testedObject, 'hex', $exampleValue);
$result = $testedObject->getHex();
$this->assertEquals($exampleValue, $result);
$this->assertSame($exampleValue, $result);
}

/**
Expand All @@ -50,7 +50,7 @@ public function testGetDec()

$this->setProtectedPropertyValue($testedObject, 'dec', $exampleValue);
$result = $testedObject->getDec();
$this->assertEquals($exampleValue, $result);
$this->assertSame($exampleValue, $result);
}

/**
Expand All @@ -75,11 +75,11 @@ public function testUnserialize()

$testedObject->unserialize($data);

$this->assertEquals('id', $testedObject->getId());
$this->assertEquals('x', $testedObject->getX());
$this->assertEquals('y', $testedObject->getY());
$this->assertEquals('hex', $testedObject->getHex());
$this->assertEquals('dec', $testedObject->getDec());
$this->assertSame('id', $testedObject->getId());
$this->assertSame('x', $testedObject->getX());
$this->assertSame('y', $testedObject->getY());
$this->assertSame('hex', $testedObject->getHex());
$this->assertSame('dec', $testedObject->getDec());
}

/**
Expand Down
12 changes: 6 additions & 6 deletions test/unit/BitPayKeyUtils/KeyHelper/PrivateKeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testSetHex()

$testedObject->setHex( $exampleValue );
$realValue = $this->accessProtected( $testedObject, 'hex' );
$this->assertEquals( $exampleValue, $realValue );
$this->assertSame( $exampleValue, $realValue );
}

/**
Expand All @@ -42,7 +42,7 @@ public function testGenerateReturnsObjectWithHexIfHexIsSet()
$testedObject->setHex( $expectedValue );
$result = $testedObject->generate();
$realValue = $this->accessProtected( $result, 'hex' );
$this->assertEquals( $expectedValue, $realValue );
$this->assertSame( $expectedValue, $realValue );
}

public function testIsValidIfKeyNotSet()
Expand Down Expand Up @@ -109,8 +109,8 @@ public function testPemDecode()
$result = $testedObject->pemDecode( self::EXAMPLE_ECDSA_KEY );

$this->assertIsArray( $result );
$this->assertEquals( '52f7b0b9e2a06703bc758cfc13e5370f7a04ec7528a728daab2ae14c21414a2c', $result[ 'private_key' ] );
$this->assertEquals(
$this->assertSame( '52f7b0b9e2a06703bc758cfc13e5370f7a04ec7528a728daab2ae14c21414a2c', $result[ 'private_key' ] );
$this->assertSame(
'045ecd459aae1074f01b9f737271d114f873a3737916f5e7dbb28da423fbdd0d359c482324df5d2ce771b7b510a50c13cfbae240b0a8216cf7da4da52999714234',
$result[ 'public_key' ] );
}
Expand Down Expand Up @@ -177,7 +177,7 @@ public function test__toStringWhenHexIsSet()
$testedObject = $this->createClassObject();
$testedObject->setHex( self::EXAMPLE_HEX_STRING );

$this->assertEquals( self::EXAMPLE_HEX_STRING, (string) $testedObject );
$this->assertSame( self::EXAMPLE_HEX_STRING, (string) $testedObject );
}

public function testGetPublicKeyIfKeyIsNull()
Expand All @@ -195,7 +195,7 @@ public function testGetPublicKeyIfKeyIsNotNull()
$secondResult = $testedObject->getPublicKey();

$this->assertInstanceOf( PublicKey::class, $firstResult );
$this->assertEquals( $firstResult, $secondResult );
$this->assertSame( $firstResult, $secondResult );
}

private function createClassObject(): PrivateKey
Expand Down
8 changes: 4 additions & 4 deletions test/unit/BitPayKeyUtils/KeyHelper/PublicKeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public function testSetPrivateKey()

$testedObject = $this->getTestedClassObject();
$testedObject->setPrivateKey($privateKeyMock);
$this->assertEquals($privateKeyMock, $this->accessProtected($testedObject, 'privateKey'));
$this->assertSame($privateKeyMock, $this->accessProtected($testedObject, 'privateKey'));
}

public function testToStringWhenXIsNull()
{
$testedObject = $this->getTestedClassObject();
$this->assertEquals('', (string)$testedObject);
$this->assertSame('', (string)$testedObject);
}

/**
Expand All @@ -47,7 +47,7 @@ public function testToStringWhenXIsNotNullAndMathModIs1()
$this->setProtectedPropertyValue($testedObject, 'y', 1);

$toStringCompressionResult = '031';
$this->assertEquals($toStringCompressionResult, (string)$testedObject);
$this->assertSame($toStringCompressionResult, (string)$testedObject);
}

/**
Expand All @@ -61,7 +61,7 @@ public function testToStringWhenXIsNotNullAndMathModIsNot1()
$this->setProtectedPropertyValue($testedObject, 'y', 4);

$toStringCompressionResult = '021';
$this->assertEquals($toStringCompressionResult, (string)$testedObject);
$this->assertSame($toStringCompressionResult, (string)$testedObject);
}

public function testIsValidWhenPublicKeyIsBlank()
Expand Down
8 changes: 4 additions & 4 deletions test/unit/BitPayKeyUtils/KeyHelper/SinKeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public function test__toStringValue(): void
$property = $this->getAccessibleProperty(SinKey::class, 'value');
$value = $property->getValue($this->sinKey);

$this->assertEquals($value, $this->sinKey->__toString());
$this->assertSame($value, $this->sinKey->__toString());
}

public function testSetPublicKey(): void
{
$publicKey = $this->getMockBuilder(PublicKey::class)->getMock();

$this->assertEquals($this->sinKey, $this->sinKey->setPublicKey($publicKey));
$this->assertSame($this->sinKey, $this->sinKey->setPublicKey($publicKey));
}

public function testGenerateWithoutPublicKey(): void
Expand All @@ -65,12 +65,12 @@ public function testIsValid(): void
$this->sinKey->setPublicKey($publicKey);
$this->sinKey->generate();

$this->assertEquals(true, $this->sinKey->isValid());
$this->assertSame(true, $this->sinKey->isValid());
}

public function testIsValidFalse(): void
{
$this->assertEquals(false, $this->sinKey->isValid());
$this->assertSame(false, $this->sinKey->isValid());
}

private function getAccessibleProperty(string $class, string $property): ReflectionProperty
Expand Down
44 changes: 22 additions & 22 deletions test/unit/BitPayKeyUtils/Math/BcEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@ public function testAdd()
$expectedValue = '12';

$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->add('5', '7'));
$this->assertSame($expectedValue, $bcEngine->add('5', '7'));
}

public function testInput()
{
$expectedValue = '5';

$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->input($expectedValue));
$this->assertSame($expectedValue, $bcEngine->input($expectedValue));
}

public function testInputNull()
{
$expectedValue = '0';

$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->input(null));
$this->assertSame($expectedValue, $bcEngine->input(null));
}

public function testInputHex()
{
$expectedValue = '86';

$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->input('0x56'));
$this->assertSame($expectedValue, $bcEngine->input('0x56'));
}

public function testInputException()
Expand All @@ -53,122 +53,122 @@ public function testInputException()

public function testCmpGreaterThan()
{
$expectedValue = '1';
$expectedValue = 1;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bccomp function will return the integer type to present compared result.


$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->cmp('9', '7'));
$this->assertSame($expectedValue, $bcEngine->cmp('9', '7'));
}

public function testCmpLessThan()
{
$expectedValue = '-1';
$expectedValue = -1;

$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->cmp('7', '9'));
$this->assertSame($expectedValue, $bcEngine->cmp('7', '9'));
}

public function testCmpEqualsTo()
{
$expectedValue = '0';
$expectedValue = 0;

$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->cmp('7', '7'));
$this->assertSame($expectedValue, $bcEngine->cmp('7', '7'));
}

public function testDiv()
{
$expectedValue = '3';

$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->div('6', '2'));
$this->assertSame($expectedValue, $bcEngine->div('6', '2'));
}

public function testInvertm()
{
$expectedValue = '0';

$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->invertm('6', '2'));
$this->assertSame($expectedValue, $bcEngine->invertm('6', '2'));
}

public function testInvertm2()
{
$expectedValue = '1';

$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->invertm('-1', '2'));
$this->assertSame($expectedValue, $bcEngine->invertm('-1', '2'));
}

public function testMod()
{
$expectedValue = '0';

$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->mod('6', '2'));
$this->assertSame($expectedValue, $bcEngine->mod('6', '2'));
}

public function testMod2()
{
$expectedValue = '2';

$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->mod('-6', '2'));
$this->assertSame($expectedValue, $bcEngine->mod('-6', '2'));
}

public function testMul()
{
$expectedValue = '21';

$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->mul('3', '7'));
$this->assertSame($expectedValue, $bcEngine->mul('3', '7'));
}

public function testPow()
{
$expectedValue = '64';

$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->pow('4', '3'));
$this->assertSame($expectedValue, $bcEngine->pow('4', '3'));
}

public function testSub()
{
$expectedValue = '18';

$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->sub('20', '2'));
$this->assertSame($expectedValue, $bcEngine->sub('20', '2'));
}

public function testCoprime()
{
$expectedValue = false;

$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->coprime('20', '2'));
$this->assertSame($expectedValue, $bcEngine->coprime('20', '2'));
}

public function testCoprime2()
{
$expectedValue = true;

$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->coprime('5', '3'));
$this->assertSame($expectedValue, $bcEngine->coprime('5', '3'));
}

public function testCoprime3()
{
$expectedValue = true;

$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->coprime('3', '5'));
$this->assertSame($expectedValue, $bcEngine->coprime('3', '5'));
}

public function testCoprime4()
{
$expectedValue = false;

$bcEngine = $this->createClassObject();
$this->assertEquals($expectedValue, $bcEngine->coprime('3', '3'));
$this->assertSame($expectedValue, $bcEngine->coprime('3', '3'));
}

private function createClassObject()
Expand Down
Loading