for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
<?php
use Automattic\Jetpack\Assets\Logo;
use PHPUnit\Framework\TestCase;
class Test_Logo extends TestCase {
/**
* Ensure the rendered logo has all the CSS classes needed for styling.
*/
function test_constructor_default_logo() {
$logo = new Logo();
$logo_render = $logo->render();
$this->assertContains( '<svg xmlns="http://www.w3.org/2000/svg"', $logo_render );
$this->assertContains( 'class="jetpack-logo"', $logo_render );
$this->assertContains( 'class="jetpack-logo__icon-circle"', $logo_render );
$this->assertEquals( 2, preg_match_all( '/class="jetpack-logo__icon-triangle"/', $logo_render ) );
$this->assertContains( 'class="jetpack-logo__text"', $logo_render );
}