Skip to content
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
30 changes: 30 additions & 0 deletions tests/PhpCollective/Sniffs/Classes/MethodDeclarationSniffTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* MIT License
* For full license information, please view the LICENSE file that was distributed with this source code.
*/

namespace PhpCollective\Test\PhpCollective\Sniffs\Classes;

use PhpCollective\Sniffs\Classes\MethodDeclarationSniff;
use PhpCollective\Test\TestCase;

class MethodDeclarationSniffTest extends TestCase
{
/**
* @return void
*/
public function testMethodDeclarationSniffer(): void
{
$this->assertSnifferFindsFixableErrors(new MethodDeclarationSniff(), 5, 4);
}

/**
* @return void
*/
public function testMethodDeclarationFixer(): void
{
$this->assertSnifferCanFixErrors(new MethodDeclarationSniff(), 4);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* MIT License
* For full license information, please view the LICENSE file that was distributed with this source code.
*/

namespace PhpCollective\Test\PhpCollective\Sniffs\Commenting;

use PhpCollective\Sniffs\Commenting\DocBlockStructureSniff;
use PhpCollective\Test\TestCase;

class DocBlockStructureSniffTest extends TestCase
{
/**
* @return void
*/
public function testDocBlockStructureSniffer(): void
{
$this->assertSnifferFindsFixableErrors(new DocBlockStructureSniff(), 3, 3);
}

/**
* @return void
*/
public function testDocBlockStructureFixer(): void
{
$this->assertSnifferCanFixErrors(new DocBlockStructureSniff(), 3);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* MIT License
* For full license information, please view the LICENSE file that was distributed with this source code.
*/

namespace PhpCollective\Test\PhpCollective\Sniffs\Commenting;

use PhpCollective\Sniffs\Commenting\DocBlockTagGroupingSniff;
use PhpCollective\Test\TestCase;

class DocBlockTagGroupingSniffTest extends TestCase
{
/**
* @return void
*/
public function testDocBlockTagGroupingSniffer(): void
{
$this->assertSnifferFindsFixableErrors(new DocBlockTagGroupingSniff(), 6, 6);
}

/**
* @return void
*/
public function testDocBlockTagGroupingFixer(): void
{
$this->assertSnifferCanFixErrors(new DocBlockTagGroupingSniff(), 6);
}
}
30 changes: 30 additions & 0 deletions tests/PhpCollective/Sniffs/Commenting/DocCommentSniffTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* MIT License
* For full license information, please view the LICENSE file that was distributed with this source code.
*/

namespace PhpCollective\Test\PhpCollective\Sniffs\Commenting;

use PhpCollective\Sniffs\Commenting\DocCommentSniff;
use PhpCollective\Test\TestCase;

class DocCommentSniffTest extends TestCase
{
/**
* @return void
*/
public function testDocCommentSniffer(): void
{
$this->assertSnifferFindsFixableErrors(new DocCommentSniff(), 4, 4);
}

/**
* @return void
*/
public function testDocCommentFixer(): void
{
$this->assertSnifferCanFixErrors(new DocCommentSniff(), 4);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* MIT License
* For full license information, please view the LICENSE file that was distributed with this source code.
*/

namespace PhpCollective\Test\PhpCollective\Sniffs\ControlStructures;

use PhpCollective\Sniffs\ControlStructures\ControlStructureSpacingSniff;
use PhpCollective\Test\TestCase;

class ControlStructureSpacingSniffTest extends TestCase
{
/**
* @return void
*/
public function testControlStructureSpacingSniffer(): void
{
$this->assertSnifferFindsFixableErrors(new ControlStructureSpacingSniff(), 6, 6);
}

/**
* @return void
*/
public function testControlStructureSpacingFixer(): void
{
$this->assertSnifferCanFixErrors(new ControlStructureSpacingSniff(), 6);
}
}
53 changes: 53 additions & 0 deletions tests/PhpCollective/Sniffs/Testing/MockSniffTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/**
* MIT License
* For full license information, please view the LICENSE file that was distributed with this source code.
*/

namespace PhpCollective\Test\PhpCollective\Sniffs\Testing;

use PHP_CodeSniffer\Sniffs\Sniff;
use PhpCollective\Sniffs\Testing\MockSniff;
use PhpCollective\Test\TestCase;

class MockSniffTest extends TestCase
{
/**
* @return void
*/
public function testMockSniffer(): void
{
$this->assertSnifferFindsFixableErrors(new MockSniff(), 6, 4);
}

/**
* @return void
*/
public function testMockFixer(): void
{
$this->assertSnifferCanFixErrors(new MockSniff(), 4);
}

/**
* @param \PHP_CodeSniffer\Sniffs\Sniff $sniffer
*
* @return string
*/
protected function getDummyFileBefore(Sniff $sniffer): string
{
$fixture = parent::getDummyFileBefore($sniffer);
$target = TMP . 'MockSniffFixtureTest.php';

if (!is_dir(TMP)) {
mkdir(TMP, 0770, true);
}
Comment on lines +42 to +44

$contents = file_get_contents($fixture);
$this->assertIsString($contents);
$result = file_put_contents($target, $contents);
$this->assertIsInt($result);

return $target;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* MIT License
* For full license information, please view the LICENSE file that was distributed with this source code.
*/

namespace PhpCollective\Test\PhpCollective\Sniffs\WhiteSpace;

use PhpCollective\Sniffs\WhiteSpace\ConcatenationSpacingSniff;
use PhpCollective\Test\TestCase;

class ConcatenationSpacingSniffTest extends TestCase
{
/**
* @return void
*/
public function testConcatenationSpacingSniffer(): void
{
$this->assertSnifferFindsFixableErrors(new ConcatenationSpacingSniff(), 4, 4);
}

/**
* @return void
*/
public function testConcatenationSpacingFixer(): void
{
$this->assertSnifferCanFixErrors(new ConcatenationSpacingSniff(), 4);
}
}
30 changes: 30 additions & 0 deletions tests/PhpCollective/Sniffs/WhiteSpace/FunctionSpacingSniffTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* MIT License
* For full license information, please view the LICENSE file that was distributed with this source code.
*/

namespace PhpCollective\Test\PhpCollective\Sniffs\WhiteSpace;

use PhpCollective\Sniffs\WhiteSpace\FunctionSpacingSniff;
use PhpCollective\Test\TestCase;

class FunctionSpacingSniffTest extends TestCase
{
/**
* @return void
*/
public function testFunctionSpacingSniffer(): void
{
$this->assertSnifferFindsFixableErrors(new FunctionSpacingSniff(), 2, 2);
}

/**
* @return void
*/
public function testFunctionSpacingFixer(): void
{
$this->assertSnifferCanFixErrors(new FunctionSpacingSniff(), 2);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* MIT License
* For full license information, please view the LICENSE file that was distributed with this source code.
*/

namespace PhpCollective\Test\PhpCollective\Sniffs\WhiteSpace;

use PhpCollective\Sniffs\WhiteSpace\ImplicitCastSpacingSniff;
use PhpCollective\Test\TestCase;

class ImplicitCastSpacingSniffTest extends TestCase
{
/**
* @return void
*/
public function testImplicitCastSpacingSniffer(): void
{
$this->assertSnifferFindsFixableErrors(new ImplicitCastSpacingSniff(), 4, 4);
}

/**
* @return void
*/
public function testImplicitCastSpacingFixer(): void
{
$this->assertSnifferCanFixErrors(new ImplicitCastSpacingSniff(), 4);
}
}
30 changes: 30 additions & 0 deletions tests/PhpCollective/Sniffs/WhiteSpace/TernarySpacingSniffTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* MIT License
* For full license information, please view the LICENSE file that was distributed with this source code.
*/

namespace PhpCollective\Test\PhpCollective\Sniffs\WhiteSpace;

use PhpCollective\Sniffs\WhiteSpace\TernarySpacingSniff;
use PhpCollective\Test\TestCase;

class TernarySpacingSniffTest extends TestCase
{
/**
* @return void
*/
public function testTernarySpacingSniffer(): void
{
$this->assertSnifferFindsFixableErrors(new TernarySpacingSniff(), 7, 7);
}

/**
* @return void
*/
public function testTernarySpacingFixer(): void
{
$this->assertSnifferCanFixErrors(new TernarySpacingSniff(), 7);
}
}
22 changes: 22 additions & 0 deletions tests/_data/ConcatenationSpacing/after.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace PhpCollective;

class ConcatenationSpacingExample
{
public function render(string $first, string $second): string
{
$missingBefore = $first . 'b';
$missingAfter = $first . 'b';
$tooManyBefore = $first . 'b';
$tooManyAfter = $first . 'b';

$valid = $first . 'b';
$multiline = $first
. $second;

return $missingBefore . $missingAfter . $tooManyBefore . $tooManyAfter . $valid . $multiline;
}
}
22 changes: 22 additions & 0 deletions tests/_data/ConcatenationSpacing/before.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace PhpCollective;

class ConcatenationSpacingExample
{
public function render(string $first, string $second): string
{
$missingBefore = $first. 'b';
$missingAfter = $first .'b';
$tooManyBefore = $first . 'b';
$tooManyAfter = $first . 'b';

$valid = $first . 'b';
$multiline = $first
. $second;

return $missingBefore . $missingAfter . $tooManyBefore . $tooManyAfter . $valid . $multiline;
}
}
Loading
Loading