Skip to content

Commit

Permalink
🚿 static calls to TestCase::assert*
Browse files Browse the repository at this point in the history
  • Loading branch information
codemasher committed Feb 19, 2020
1 parent 551150b commit 4173015
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 94 deletions.
8 changes: 4 additions & 4 deletions tests/Data/DatainterfaceTestAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ protected function setUp():void{
public function testInstance(){
$this->dataInterface = $this->reflection->newInstanceArgs([new QROptions, $this->testdata]);

$this->assertInstanceOf(QRDataInterface::class, $this->dataInterface);
$this::assertInstanceOf(QRDataInterface::class, $this->dataInterface);
}

public function testSetData(){
$this->dataInterface->setData($this->testdata);

$this->assertSame($this->expected, $this->getProperty('matrixdata')->getValue($this->dataInterface));
$this::assertSame($this->expected, $this->getProperty('matrixdata')->getValue($this->dataInterface));
}

public function testInitMatrix(){
$m = $this->dataInterface->setData($this->testdata)->initMatrix(0);

$this->assertInstanceOf(QRMatrix::class, $m);
$this::assertInstanceOf(QRMatrix::class, $m);
}

public function testGetMinimumVersion(){
$this->assertSame(1, $this->getMethod('getMinimumVersion')->invoke($this->dataInterface));
$this::assertSame(1, $this->getMethod('getMinimumVersion')->invoke($this->dataInterface));
}

public function testGetMinimumVersionException(){
Expand Down
2 changes: 1 addition & 1 deletion tests/Data/MaskPatternTesterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MaskPatternTesterTest extends QRTestAbstract{
public function testMaskpattern(){
$matrix = (new Byte(new QROptions(['version' => 10]), 'test'))->initMatrix(0, true);

$this->assertSame(6178, (new MaskPatternTester($matrix))->testPattern());
$this::assertSame(6178, (new MaskPatternTester($matrix))->testPattern());
}


Expand Down
72 changes: 36 additions & 36 deletions tests/Data/QRMatrixTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,56 +46,56 @@ public function testInvalidEccException(){
}

public function testInstance(){
$this->assertInstanceOf($this->FQCN, $this->matrix);
$this::assertInstanceOf($this->FQCN, $this->matrix);
}

public function testSize(){
$this->assertCount($this->matrix->size(), $this->matrix->matrix());
$this::assertCount($this->matrix->size(), $this->matrix->matrix());
}

public function testVersion(){
$this->assertSame($this->version, $this->matrix->version());
$this::assertSame($this->version, $this->matrix->version());
}

public function testECC(){
$this->assertSame(QRCode::ECC_L, $this->matrix->eccLevel());
$this::assertSame(QRCode::ECC_L, $this->matrix->eccLevel());
}

public function testMaskPattern(){
$this->assertSame(-1, $this->matrix->maskPattern());
$this::assertSame(-1, $this->matrix->maskPattern());
}

public function testGetSetCheck(){
$this->matrix->set(10, 10, true, QRMatrix::M_TEST);
$this->assertSame(65280, $this->matrix->get(10, 10));
$this->assertTrue($this->matrix->check(10, 10));
$this::assertSame(65280, $this->matrix->get(10, 10));
$this::assertTrue($this->matrix->check(10, 10));

$this->matrix->set(20, 20, false, QRMatrix::M_TEST);
$this->assertSame(255, $this->matrix->get(20, 20));
$this->assertFalse($this->matrix->check(20, 20));
$this::assertSame(255, $this->matrix->get(20, 20));
$this::assertFalse($this->matrix->check(20, 20));
}

public function testSetDarkModule(){
$this->matrix->setDarkModule();

$this->assertSame(QRMatrix::M_DARKMODULE << 8, $this->matrix->get(8, $this->matrix->size() - 8));
$this::assertSame(QRMatrix::M_DARKMODULE << 8, $this->matrix->get(8, $this->matrix->size() - 8));
}

public function testSetFinderPattern(){
$this->matrix->setFinderPattern();

$this->assertSame(QRMatrix::M_FINDER << 8, $this->matrix->get(0, 0));
$this->assertSame(QRMatrix::M_FINDER << 8, $this->matrix->get(0, $this->matrix->size() - 1));
$this->assertSame(QRMatrix::M_FINDER << 8, $this->matrix->get($this->matrix->size() - 1, 0));
$this::assertSame(QRMatrix::M_FINDER << 8, $this->matrix->get(0, 0));
$this::assertSame(QRMatrix::M_FINDER << 8, $this->matrix->get(0, $this->matrix->size() - 1));
$this::assertSame(QRMatrix::M_FINDER << 8, $this->matrix->get($this->matrix->size() - 1, 0));
}

public function testSetSeparators(){
$this->matrix->setSeparators();

$this->assertSame(QRMatrix::M_SEPARATOR, $this->matrix->get(7, 0));
$this->assertSame(QRMatrix::M_SEPARATOR, $this->matrix->get(0, 7));
$this->assertSame(QRMatrix::M_SEPARATOR, $this->matrix->get(0, $this->matrix->size() - 8));
$this->assertSame(QRMatrix::M_SEPARATOR, $this->matrix->get($this->matrix->size() - 8, 0));
$this::assertSame(QRMatrix::M_SEPARATOR, $this->matrix->get(7, 0));
$this::assertSame(QRMatrix::M_SEPARATOR, $this->matrix->get(0, 7));
$this::assertSame(QRMatrix::M_SEPARATOR, $this->matrix->get(0, $this->matrix->size() - 8));
$this::assertSame(QRMatrix::M_SEPARATOR, $this->matrix->get($this->matrix->size() - 8, 0));
}

public function testSetAlignmentPattern(){
Expand All @@ -110,11 +110,11 @@ public function testSetAlignmentPattern(){
foreach($alignmentPattern as $px){

if($this->matrix->get($px, $py) === QRMatrix::M_FINDER << 8){
$this->assertSame(QRMatrix::M_FINDER << 8, $this->matrix->get($px, $py), 'skipped finder pattern');
$this::assertSame(QRMatrix::M_FINDER << 8, $this->matrix->get($px, $py), 'skipped finder pattern');
continue;
}

$this->assertSame(QRMatrix::M_ALIGNMENT << 8, $this->matrix->get($px, $py));
$this::assertSame(QRMatrix::M_ALIGNMENT << 8, $this->matrix->get($px, $py));
}
}

Expand All @@ -133,32 +133,32 @@ public function testSetTimingPattern(){
$p1 = $this->matrix->get(6, $i);

if($p1 === QRMatrix::M_ALIGNMENT << 8){
$this->assertSame(QRMatrix::M_ALIGNMENT << 8, $p1, 'skipped alignment pattern');
$this::assertSame(QRMatrix::M_ALIGNMENT << 8, $p1, 'skipped alignment pattern');
continue;
}

$this->assertSame(QRMatrix::M_TIMING << 8, $p1);
$this->assertSame(QRMatrix::M_TIMING << 8, $this->matrix->get($i, 6));
$this::assertSame(QRMatrix::M_TIMING << 8, $p1);
$this::assertSame(QRMatrix::M_TIMING << 8, $this->matrix->get($i, 6));
}
}
}

public function testSetVersionNumber(){
$this->matrix->setVersionNumber(true);

$this->assertSame(QRMatrix::M_VERSION, $this->matrix->get($this->matrix->size() - 9, 0));
$this->assertSame(QRMatrix::M_VERSION, $this->matrix->get($this->matrix->size() - 11, 5));
$this->assertSame(QRMatrix::M_VERSION, $this->matrix->get(0, $this->matrix->size() - 9));
$this->assertSame(QRMatrix::M_VERSION, $this->matrix->get(5, $this->matrix->size() - 11));
$this::assertSame(QRMatrix::M_VERSION, $this->matrix->get($this->matrix->size() - 9, 0));
$this::assertSame(QRMatrix::M_VERSION, $this->matrix->get($this->matrix->size() - 11, 5));
$this::assertSame(QRMatrix::M_VERSION, $this->matrix->get(0, $this->matrix->size() - 9));
$this::assertSame(QRMatrix::M_VERSION, $this->matrix->get(5, $this->matrix->size() - 11));
}

public function testSetFormatInfo(){
$this->matrix->setFormatInfo(0, true);

$this->assertSame(QRMatrix::M_FORMAT, $this->matrix->get(8, 0));
$this->assertSame(QRMatrix::M_FORMAT, $this->matrix->get(0, 8));
$this->assertSame(QRMatrix::M_FORMAT, $this->matrix->get($this->matrix->size() - 1, 8));
$this->assertSame(QRMatrix::M_FORMAT, $this->matrix->get($this->matrix->size() - 8, 8));
$this::assertSame(QRMatrix::M_FORMAT, $this->matrix->get(8, 0));
$this::assertSame(QRMatrix::M_FORMAT, $this->matrix->get(0, 8));
$this::assertSame(QRMatrix::M_FORMAT, $this->matrix->get($this->matrix->size() - 1, 8));
$this::assertSame(QRMatrix::M_FORMAT, $this->matrix->get($this->matrix->size() - 8, 8));
}

public function testSetQuietZone(){
Expand All @@ -170,15 +170,15 @@ public function testSetQuietZone(){

$this->matrix->setQuietZone($q);

$this->assertCount($size + 2 * $q, $this->matrix->matrix());
$this->assertCount($size + 2 * $q, $this->matrix->matrix()[$size - 1]);
$this::assertCount($size + 2 * $q, $this->matrix->matrix());
$this::assertCount($size + 2 * $q, $this->matrix->matrix()[$size - 1]);

$size = $this->matrix->size();
$this->assertSame(QRMatrix::M_QUIETZONE, $this->matrix->get(0, 0));
$this->assertSame(QRMatrix::M_QUIETZONE, $this->matrix->get($size - 1, $size - 1));
$this::assertSame(QRMatrix::M_QUIETZONE, $this->matrix->get(0, 0));
$this::assertSame(QRMatrix::M_QUIETZONE, $this->matrix->get($size - 1, $size - 1));

$this->assertSame(QRMatrix::M_TEST << 8, $this->matrix->get($q, $q));
$this->assertSame(QRMatrix::M_TEST << 8, $this->matrix->get($size - 1 - $q, $size - 1 - $q));
$this::assertSame(QRMatrix::M_TEST << 8, $this->matrix->get($q, $q));
$this::assertSame(QRMatrix::M_TEST << 8, $this->matrix->get($size - 1 - $q, $size - 1 - $q));
}

public function testSetQuietZoneException(){
Expand Down
8 changes: 4 additions & 4 deletions tests/Helpers/BitBufferTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ public function bitProvider(){
*/
public function testPut($data, $value){
$this->bitBuffer->put($data, 4);
$this->assertSame($value, $this->bitBuffer->buffer[0]);
$this->assertSame(4, $this->bitBuffer->length);
$this::assertSame($value, $this->bitBuffer->buffer[0]);
$this::assertSame(4, $this->bitBuffer->length);
}

public function testClear(){
$this->bitBuffer->clear();
$this->assertSame([], $this->bitBuffer->buffer);
$this->assertSame(0, $this->bitBuffer->length);
$this::assertSame([], $this->bitBuffer->buffer);
$this::assertSame(0, $this->bitBuffer->length);
}

}
6 changes: 3 additions & 3 deletions tests/Helpers/PolynomialTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ protected function setUp():void{
}

public function testGexp(){
$this->assertSame(142, $this->polynomial->gexp(-1));
$this->assertSame(133, $this->polynomial->gexp(128));
$this->assertSame(2, $this->polynomial->gexp(256));
$this::assertSame(142, $this->polynomial->gexp(-1));
$this::assertSame(133, $this->polynomial->gexp(128));
$this::assertSame(2, $this->polynomial->gexp(256));
}

public function testGlogException(){
Expand Down
4 changes: 2 additions & 2 deletions tests/Output/QRImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testImageOutput($type){
$this->markAsRisky();
}

$this->assertSame($img, file_get_contents($this::cachefile.$type));
$this::assertSame($img, file_get_contents($this::cachefile.$type));
}

public function testSetModuleValues(){
Expand All @@ -55,7 +55,7 @@ public function testSetModuleValues(){

$this->setOutputInterface()->dump();

$this->assertTrue(true); // tricking the code coverage
$this::assertTrue(true); // tricking the code coverage
}

}
4 changes: 2 additions & 2 deletions tests/Output/QRImagickTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testImageOutput(){
$this->outputInterface->dump($this::cachefile.$type);
$img = $this->outputInterface->dump();

$this->assertSame($img, file_get_contents($this::cachefile.$type));
$this::assertSame($img, file_get_contents($this::cachefile.$type));
}

public function testSetModuleValues(){
Expand All @@ -49,7 +49,7 @@ public function testSetModuleValues(){

$this->setOutputInterface()->dump();

$this->assertTrue(true); // tricking the code coverage
$this::assertTrue(true); // tricking the code coverage
}

}
8 changes: 4 additions & 4 deletions tests/Output/QRMarkupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testMarkupOutputFile($type){
$this->setOutputInterface();
$data = $this->outputInterface->dump();

$this->assertSame($data, file_get_contents($this->options->cachefile));
$this::assertSame($data, file_get_contents($this->options->cachefile));
}

/**
Expand All @@ -57,7 +57,7 @@ public function testMarkupOutput($type){

$expected = implode($this->options->eol, $expected);

$this->assertSame(trim($expected), trim($this->outputInterface->dump()));
$this::assertSame(trim($expected), trim($this->outputInterface->dump()));
}

public function testSetModuleValues(){
Expand All @@ -70,8 +70,8 @@ public function testSetModuleValues(){

$this->setOutputInterface();
$data = $this->outputInterface->dump();
$this->assertStringContainsString('#4A6000', $data);
$this->assertStringContainsString('#ECF9BE', $data);
$this::assertStringContainsString('#4A6000', $data);
$this::assertStringContainsString('#ECF9BE', $data);
}

}
2 changes: 1 addition & 1 deletion tests/Output/QROutputTestAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function setOutputInterface(){
}

public function testInstance(){
$this->assertInstanceOf(QROutputInterface::class, $this->outputInterface);
$this::assertInstanceOf(QROutputInterface::class, $this->outputInterface);
}

public function testSaveException(){
Expand Down
6 changes: 3 additions & 3 deletions tests/Output/QRStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testStringOutput($type){
$this->setOutputInterface();
$data = $this->outputInterface->dump();

$this->assertSame($data, file_get_contents($this->options->cachefile));
$this::assertSame($data, file_get_contents($this->options->cachefile));
}

public function testSetModuleValues(){
Expand All @@ -49,8 +49,8 @@ public function testSetModuleValues(){
$this->setOutputInterface();
$data = $this->outputInterface->dump();

$this->assertStringContainsString('A', $data);
$this->assertStringContainsString('B', $data);
$this::assertStringContainsString('A', $data);
$this::assertStringContainsString('B', $data);
}

}
32 changes: 16 additions & 16 deletions tests/QRCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ protected function setUp():void{
}

public function testIsNumber(){
$this->assertTrue($this->qrcode->isNumber('0123456789'));
$this->assertFalse($this->qrcode->isNumber('ABC'));
$this::assertTrue($this->qrcode->isNumber('0123456789'));
$this::assertFalse($this->qrcode->isNumber('ABC'));
}

public function testIsAlphaNum(){
$this->assertTrue($this->qrcode->isAlphaNum('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./:'));
$this->assertFalse($this->qrcode->isAlphaNum('abc'));
$this::assertTrue($this->qrcode->isAlphaNum('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./:'));
$this::assertFalse($this->qrcode->isAlphaNum('abc'));
}

public function testIsKanji(){
$this->assertTrue($this->qrcode->isKanji('茗荷'));
$this->assertFalse($this->qrcode->isKanji('Ã'));
$this::assertTrue($this->qrcode->isKanji('茗荷'));
$this::assertFalse($this->qrcode->isKanji('Ã'));
}

// coverage
Expand All @@ -70,7 +70,7 @@ public function typeDataProvider(){
public function testRenderImage($type, $expected){
$this->qrcode = $this->reflection->newInstanceArgs([new QROptions(['outputType' => $type])]);

$this->assertStringContainsString($expected, $this->qrcode->render('test'));
$this::assertStringContainsString($expected, $this->qrcode->render('test'));
}

public function testInitDataInterfaceException(){
Expand All @@ -91,13 +91,13 @@ public function testTrim() {
$m1 = $this->qrcode->getMatrix('hello');
$m2 = $this->qrcode->getMatrix('hello '); // added space

$this->assertNotEquals($m1, $m2);
$this::assertNotEquals($m1, $m2);
}

public function testImageTransparencyBGDefault(){
$this->qrcode = $this->reflection->newInstanceArgs([new QROptions(['imageTransparencyBG' => ['foo']])]);

$this->assertSame([255,255,255], $this->getProperty('options')->getValue($this->qrcode)->imageTransparencyBG);
$this::assertSame([255,255,255], $this->getProperty('options')->getValue($this->qrcode)->imageTransparencyBG);
}

public function testCustomOutput(){
Expand All @@ -111,21 +111,21 @@ public function testCustomOutput(){

$expected = '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111110111010000101111010000011111110000000010000010111000001101011000001010000010000000010111010101101011000001101011010111010000000010111010110100111110010100111010111010000000010111010000001101011000001101010111010000000010000010100111110010100111110010000010000000011111110101010101010101010101011111110000000000000000010010100111110010100000000000000000011001110000101111010000101111001011110000000000000000111010000101111010000111100010000000001011010100111110010100111110011001010000000010000101111101011000001101011110011110000000000011010100011000001101011000101110100000000011001100001001101011000001101010011010000000010110111110000001101011000001100110100000000010000100100010100111110010100001100100000000011111110111101111010000101111010100110000000011010000111010000101111010000111100100000000010101111111111110010100111110011001000000000010110001110101011000001101011110011010000000001001111100011000001101011000101110010000000011000100110001101011000001101010011100000000001000011001000001101011000001100110000000000011101001011010100111110010100001100000000000010111010001101111010000101111010100110000000011100000001010000101111010000111100000000000000001110110111110010100111110011001000000000000011001011101011000001101011110011100000000011111110101011000001101011001111110110000000000000000110001101011000001101000111100000000011111110001000001101011000011010110000000000010000010101010100111110010101000100100000000010111010111101111010000101111111100110000000010111010011010000101111010001101100010000000010111010000111110010100111100101101100000000010000010101101011000001101001100111100000000011111110101011000001101011000110010110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';

$this->assertSame($expected, $this->reflection->newInstanceArgs([$options])->render('test'));
$this::assertSame($expected, $this->reflection->newInstanceArgs([$options])->render('test'));
}

public function testDataModeOverride(){
$this->qrcode = $this->reflection->newInstance();

$this->assertInstanceOf(Number::class, $this->qrcode->initDataInterface('123'));
$this->assertInstanceOf(AlphaNum::class, $this->qrcode->initDataInterface('ABC123'));
$this->assertInstanceOf(Byte::class, $this->qrcode->initDataInterface(random_bytes(32)));
$this::assertInstanceOf(Number::class, $this->qrcode->initDataInterface('123'));
$this::assertInstanceOf(AlphaNum::class, $this->qrcode->initDataInterface('ABC123'));
$this::assertInstanceOf(Byte::class, $this->qrcode->initDataInterface(random_bytes(32)));

$this->qrcode = $this->reflection->newInstanceArgs([new QROptions(['dataMode' => 'Byte'])]);

$this->assertInstanceOf(Byte::class, $this->qrcode->initDataInterface('123'));
$this->assertInstanceOf(Byte::class, $this->qrcode->initDataInterface('ABC123'));
$this->assertInstanceOf(Byte::class, $this->qrcode->initDataInterface(random_bytes(32)));
$this::assertInstanceOf(Byte::class, $this->qrcode->initDataInterface('123'));
$this::assertInstanceOf(Byte::class, $this->qrcode->initDataInterface('ABC123'));
$this::assertInstanceOf(Byte::class, $this->qrcode->initDataInterface(random_bytes(32)));
}

public function testDataModeOverrideError(){
Expand Down

0 comments on commit 4173015

Please sign in to comment.