Skip to content

Commit

Permalink
Replaced MemoryLeakTest with ReflectorMemoryTest
Browse files Browse the repository at this point in the history
  • Loading branch information
vudaltsov committed Feb 20, 2024
1 parent bb8366b commit acdb816
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 96 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
"autoload-dev": {
"psr-4": {
"Typhoon\\Reflection\\": [
"tests/unit",
"tests/memory"
"tests/unit"
]
}
},
Expand Down
3 changes: 0 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
<testsuite name="unit">
<directory>tests/unit</directory>
</testsuite>
<testsuite name="memory">
<directory>tests/memory</directory>
</testsuite>
</testsuites>

<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
Expand Down
91 changes: 0 additions & 91 deletions tests/memory/MemoryLeakTest.php

This file was deleted.

28 changes: 28 additions & 0 deletions tests/unit/ReflectorMemoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Typhoon\Reflection;

use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
use PHPUnit\Framework\TestCase;

#[CoversNothing]
final class ReflectorMemoryTest extends TestCase
{
#[RunInSeparateProcess]
public function testItIsGarbageCollected(): void
{
gc_disable();
$reflector = TyphoonReflector::build();
$reflection = $reflector->reflectClass(\AppendIterator::class);
$weakReflector = \WeakReference::create($reflector);
$weakReflection = \WeakReference::create($reflection);

unset($reflector, $reflection);

self::assertNull($weakReflector->get());
self::assertNull($weakReflection->get());
}
}

0 comments on commit acdb816

Please sign in to comment.