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 90e46d1 commit da71d5a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 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
13 changes: 13 additions & 0 deletions Tests/Utils/UseStatements/SplitAndMergeImportUseStatementTest.php
Expand Up @@ -25,6 +25,19 @@
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 da71d5a

Please sign in to comment.