dg / bypass-finals

Removes `final` and `readonly` keywords from source code on-the-fly and allows mocking of final methods and classes. It can be used together with any test tool such as PHPUnit or Mockery.
Other
487 stars 30 forks source link

Unsure of the true cause, but enabling BypassFinals causes unrelated test to fail in our project #50

Open sd-matt-b opened 9 months ago

sd-matt-b commented 9 months ago

The test uses SplFireObject to get a line count from a .tsv file.

    $fileInfo = new \SplFileObject($fileName);
    $fileInfo->seek(\PHP_INT_MAX);
    $lineCount = $fileInfo->key();

The file in question returns (for example) 100 when not using BypassFinals::enable(), but when used the test returns 99 when using. I've tested this and it appears that BypassFinals is somehow trimming a trailing new line in our .tsv which causes the test to fail. Using a strict whitelist does not seem to alleviate this issue.

What I can't determine is the root cause, I can't tell if this is a BypassFinals issue, or if there's something about this project's setup that merely gets triggered by BypassFinals. Either way, feels like I should leave this issue in case anyone else wants to look deeper or runs into a similar issue.

dg commented 8 months ago

I can confirm that this is happening, but I have no idea why.

srgpsk commented 2 months ago

We have a very similar issue and it's also related to file system abstraction. Also adding denyPaths() for that part doesn't help.

wikando-ck commented 2 months ago

I have the same issue, it's present since v1.6

dg commented 2 months ago

@wikando-ck this problem has existed since the very first version