mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
first
This commit is contained in:
16
tests/PHPUnit/CustomTestCase/CustomTestCase.php
Normal file
16
tests/PHPUnit/CustomTestCase/CustomTestCase.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\CustomTestCase;
|
||||
|
||||
use function PHPUnit\Framework\assertTrue;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CustomTestCase extends TestCase
|
||||
{
|
||||
public function assertCustomTrue()
|
||||
{
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
23
tests/PHPUnit/CustomTestCase/PhpunitTest.php
Normal file
23
tests/PHPUnit/CustomTestCase/PhpunitTest.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\CustomTestCase;
|
||||
|
||||
use function PHPUnit\Framework\assertTrue;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PhpunitTest extends TestCase
|
||||
{
|
||||
public static $executed = false;
|
||||
|
||||
/** @test */
|
||||
public function testThatGetsExecuted(): void
|
||||
{
|
||||
self::$executed = true;
|
||||
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
// register_shutdown_function(fn () => assertTrue(PhpunitTest::$executed));
|
||||
7
tests/PHPUnit/CustomTestCase/UsesPerDirectory.php
Normal file
7
tests/PHPUnit/CustomTestCase/UsesPerDirectory.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
uses(Tests\CustomTestCase\CustomTestCase::class)->in(__DIR__);
|
||||
|
||||
test('closure was bound to CustomTestCase', function () {
|
||||
$this->assertCustomTrue();
|
||||
});
|
||||
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\SubFolder\SubFolder\SubFolder;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CustomTestCaseInSubFolder extends TestCase
|
||||
{
|
||||
public function assertCustomInSubFolderTrue()
|
||||
{
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
test('closure was bound to CustomTestCase', function () {
|
||||
$this->assertCustomInSubFolderTrue();
|
||||
});
|
||||
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
trait MyCustomTrait
|
||||
{
|
||||
public function assertFalseIsFalse()
|
||||
{
|
||||
assertFalse(false);
|
||||
}
|
||||
}
|
||||
|
||||
class MyCustomClass extends PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function assertTrueIsTrue()
|
||||
{
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
uses(MyCustomClass::class, MyCustomTrait::class);
|
||||
|
||||
test('custom traits can be used', function () {
|
||||
$this->assertTrueIsTrue();
|
||||
});
|
||||
|
||||
test('trait applied in this file')->assertTrueIsTrue();
|
||||
3
tests/PHPUnit/Pest.php
Normal file
3
tests/PHPUnit/Pest.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
uses(Tests\SubFolder\SubFolder\SubFolder\CustomTestCaseInSubFolder::class)->in('CustomTestCaseInSubFolders/SubFolder');
|
||||
Reference in New Issue
Block a user