Skip to content

Commit

Permalink
Run phpunit with process insolation argument
Browse files Browse the repository at this point in the history
  • Loading branch information
rafageist committed Sep 9, 2024
1 parent f74d07c commit b3f24b3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
- name: Run PHPUnit tests
run: |
vendor/bin/phpunit
vendor/bin/phpunit --process-isolation
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,41 @@ class LazeTest extends \PHPUnit\Framework\TestCase {

```

## How to reset Laze during testing

If you need to reset Laze during testing, you have two options:

1. Using reflection to reset the internal state of Laze.

```php
class LazeTest extends \PHPUnit\Framework\TestCase {

public $lazeBackup;

public function setUp(): void {
parent::setUp();
$reflection = new ReflectionClass(laze::class);
$property = $reflection->getProperty('store');
$property->setAccessible(true);
$this->lazeBackup = $property->getValue();
}

public function tearDown(): void {
$reflection = new ReflectionClass(laze::class);
$property = $reflection->getProperty('store');
$property->setAccessible(true);
$property->setValue($this->lazeBackup);
parent::tearDown();
}
}
```

2. If you are using `phpunit`, then use it with the parameter `--process-isolation` to run each test in a separate process.

```bash
vendor/bin/phpunit --process-isolation
```

## Utility of this library

- **Lazy Evaluation**: Optimizes resource usage by deferring value evaluation until needed, improving performance and load times.
Expand Down

0 comments on commit b3f24b3

Please sign in to comment.