Skip to content

Commit

Permalink
[squash] Add tests for the changes in "catch" behaviour affected by t…
Browse files Browse the repository at this point in the history
…he new exceptions
  • Loading branch information
jrfnl committed May 14, 2024
1 parent 97a04e6 commit b03bf36
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
Expand Up @@ -40,6 +40,39 @@ final class AbstractArrayDeclarationSniffTest extends PolyfilledTestCase
'processComma',
];

/**
* Test receiving an expected exception when an non-integer token pointer is passed.
*
* @return void
*/
public function testNonIntegerToken()
{
$this->expectException('PHPCSUtils\Exceptions\TypeError');
$this->expectExceptionMessage('Argument #2 ($stackPtr) must be of type integer, boolean given');

$mockObj = $this->getMockedClassUnderTest();

$mockObj->expects($this->never())
->method('processOpenClose');

$mockObj->expects($this->never())
->method('processKey');

$mockObj->expects($this->never())
->method('processNoKey');

$mockObj->expects($this->never())
->method('processArrow');

$mockObj->expects($this->never())
->method('processValue');

$mockObj->expects($this->never())
->method('processComma');

$mockObj->process(self::$phpcsFile, false);
}

/**
* Test receiving an expected exception when an invalid token pointer is passed.
*
Expand Down
17 changes: 15 additions & 2 deletions Tests/Utils/UseStatements/SplitAndMergeImportUseStatementTest.php
Expand Up @@ -10,7 +10,7 @@

namespace PHPCSUtils\Tests\Utils\UseStatements;

use PHPCSUtils\TestUtils\UtilityMethodTestCase;
use PHPCSUtils\Tests\PolyfilledTestCase;
use PHPCSUtils\Utils\UseStatements;

/**
Expand All @@ -22,9 +22,22 @@
*
* @since 1.0.0
*/
final class SplitAndMergeImportUseStatementTest extends UtilityMethodTestCase
final class SplitAndMergeImportUseStatementTest extends PolyfilledTestCase
{

/**
* Test passing a non-integer token pointer.
*
* @return void
*/
public function testNonIntegerToken()
{
$this->expectException('PHPCSUtils\Exceptions\TypeError');
$this->expectExceptionMessage('Argument #2 ($stackPtr) must be of type integer, NULL given');

UseStatements::splitAndMergeImportUseStatement(self::$phpcsFile, null, []);
}

/**
* Test passing a non-existent token pointer.
*
Expand Down

0 comments on commit b03bf36

Please sign in to comment.