Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests\Core\AbstractMethodUnitTest: add new getTargetToken() method
This adds a new `getTargetToken()` method which can retrieve the target token for testing with higher precision than the (duplicate) code which was so far used in the individual test methods. The improvements this method offers are: * Avoid test leaking/contamination. If/when the token to start the test from was retrieved by doing a `findNext()` from the delimiter comment, a typo could cause a token from the *next* test to be used for the testing instead of the target token. If the expected results would be the same for both tests, this would go completely unnoticed. This is now no longer possible. The only requirement is that the delimiter comments start with `/* test...`. * No more token counting when setting up the unit tests, just pass the target token type constant to this method and it will get you the correct token. This also allows for not having to jump through hoops when deciding where to place the delimiter comment for the test. * If the token a test looks for is a `T_STRING` or text based token, the optional `$tokenContent` allows for selecting the correct token, even when there are several of the same type in the test case line.
- Loading branch information