pestphp / pest

Pest is an elegant PHP testing Framework with a focus on simplicity, meticulously designed to bring back the joy of testing in PHP.
https://pestphp.com
MIT License
9.12k stars 319 forks source link

[Bug]: Incorrect $this Binding In Test #1039

Closed darrencoutts118 closed 5 months ago

darrencoutts118 commented 7 months ago

What Happened

I expected that the $this variable in the test closure would be bound to the class specified in uses(...), however this is not happening.

How to Reproduce

Example Test Code

<?php

uses(AppKit\UI\Tests\TestCase::class);

it('can be integrated into a component', function () {
    dd(get_class($this));
});

When this is run, I get the following output

./vendor/bin/pest --filter Component

WARN  No code coverage driver available
"P\Tests\ComponentIntegratrionTest" // /workspaces/ui/tests/ComponentIntegratrionTest.php:6

Sample Repository

No response

Pest Version

2.28

PHP Version

8.2.9

Operation System

Linux (Github Codespaces)

Notes

No response

darrencoutts118 commented 7 months ago

I should also add that this is based on my understanding, and from the examples, on this page https://pestphp.com/docs/configuring-tests

aerni commented 5 months ago

I'm running into the same issue on Pest v2.32.0 and PHP 8.2.15.

nunomaduro commented 5 months ago

The class P\Tests\ComponentIntegratrionTest extends AppKit\UI\Tests\TestCase.