for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
// php artisan test
namespace Tests\Unit;
use PHPUnit\Framework\TestCase;
use Joki20\Http\Controllers\PokerSquares;
use Joki20\Http\Controllers\Scoring;
/**
* Test cases for trait Scoring.
*/
class ScoringTestTrait extends TestCase
{
// /**
// * Construct object and verify that the object is instance of class
// */
public function testCreateObjectPokerSquares()
$pokersquares = new PokerSquares();
$this->assertInstanceOf("\Joki20\Http\Controllers\PokerSquares", $pokersquares);
}
public function testCheckFullRow()
$pokersquares
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
$myVar = 'Value'; $higher = false; if (rand(1, 6) > 3) { $higher = true; } else { $higher = false; }
Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.
$myVar
$higher
$this->currentSession = 234;
currentSession
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
$pokerSquares->checkFullRow();
$pokerSquares
This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.
The variable may have been renamed without also renaming all references.
var_dump($this->suitsRow);
suitsRow
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.