---
title: "#phpunit articles | Hashnode"
description: "Explore 82 articles tagged #phpunit on Hashnode. Tutorials, guides, and how-tos from the community."
url: "https://hashnode.com/tag/phpunit"
---

Tag

# #phpunit

82 posts · 91 followers

[Michał Iżewski](https://hashnode.com/@michal-izewski) · [Apr 27](https://hashnode.com/posts/optimizing-monorepo-ci-cd-pipeline/69ef085198160f464f60a6d6)

### [How I Cut Our CI/CD Pipeline from 35 to 5 Minutes (And Saved the Team's Sanity)](https://blog.iamdev.pl/optimizing-monorepo-ci-cd-pipeline?utm_source=hashnode&utm_medium=feed)

How we slashed CI/CD pipeline time for a massive monorepo by identifying I/O bottlenecks and tuning OPcache for CLI

11 min read · [blog.iamdev.pl](https://blog.iamdev.pl/optimizing-monorepo-ci-cd-pipeline?utm_source=hashnode&utm_medium=feed)

[victorstackAI](https://hashnode.com/@victorstackai) · [Mar 10](https://hashnode.com/posts/assertequalhtml-in-wordpress-kill-your-brittle-html-tests/69b0333d6b0770cc8f2528ef)

### [assertEqualHTML() in WordPress: Kill Your Brittle HTML Tests](https://victorstackai.hashnode.dev/assertequalhtml-in-wordpress-kill-your-brittle-html-tests?utm_source=hashnode&utm_medium=feed)

How to migrate WordPress plugin tests to assertEqualHTML() for semantic HTML comparison. Drupal developers using PHPUnit for render tests face the same brittle-assertion problem.

4 min read · [victorstackai.hashnode.dev](https://victorstackai.hashnode.dev/assertequalhtml-in-wordpress-kill-your-brittle-html-tests?utm_source=hashnode&utm_medium=feed)

[recca0120](https://hashnode.com/@recca0120) · [Mar 8](https://hashnode.com/posts/phpunit-sleep-1/69add9aabc4378bf8e67b28f)

### [PHPUnit: Mock sleep() in 2 Ways Without Waiting](https://recca0120.hashnode.dev/phpunit-sleep-1?utm_source=hashnode&utm_medium=feed)

When sleep() slows PHPUnit tests, extract a Clock class and use Mockery spy to replace it, or use php-mock to mock the built-in function with no code changes.

2 min read · [recca0120.hashnode.dev](https://recca0120.hashnode.dev/phpunit-sleep-1?utm_source=hashnode&utm_medium=feed)

[recca0120](https://hashnode.com/@recca0120) · [Mar 8](https://hashnode.com/posts/laravel-testing-mock-server-variables-1-1-1/69add9943b6e21227e777342)

### [2 Ways to Fake $\_SERVER Variables in Laravel Feature Tests](https://recca0120.hashnode.dev/laravel-testing-mock-server-variables-1-1-1?utm_source=hashnode&utm_medium=feed)

Fake $\_SERVER in Laravel feature tests by passing server vars per-request, or use withServerVariables() to apply them globally for the entire test method.

1 min read · [recca0120.hashnode.dev](https://recca0120.hashnode.dev/laravel-testing-mock-server-variables-1-1-1?utm_source=hashnode&utm_medium=feed)

[recca0120](https://hashnode.com/@recca0120) · [Mar 8](https://hashnode.com/posts/how-to-test-closure-in-phpunit-1/69add9793db07d80867ebed5)

### [PHPUnit: Test Closures with Mockery::spy](https://recca0120.hashnode.dev/how-to-test-closure-in-phpunit-1?utm_source=hashnode&utm_medium=feed)

Assertions inside a closure pass silently even if never called. Wrap the closure in Mockery::spy to verify invocation count and arguments in PHPUnit tests.

1 min read · [recca0120.hashnode.dev](https://recca0120.hashnode.dev/how-to-test-closure-in-phpunit-1?utm_source=hashnode&utm_medium=feed)

[recca0120](https://hashnode.com/@recca0120) · [Mar 3](https://hashnode.com/posts/mockery-capturing-arguments/69a63e32edbe7b25ac9f577e)

### [Write Deterministic PHPUnit Assertions with Mockery::capture](https://recca0120.hashnode.dev/mockery-capturing-arguments?utm_source=hashnode&utm_medium=feed)

When a method uses random\_int internally, Mockery::capture with passthru captures the intermediate value so you can compute the expected result and assert it.

2 min read · [recca0120.hashnode.dev](https://recca0120.hashnode.dev/mockery-capturing-arguments?utm_source=hashnode&utm_medium=feed)

[recca0120](https://hashnode.com/@recca0120) · [Mar 3](https://hashnode.com/posts/laravel-testing-what-happens-after-a-redirect/69a63e077c322c8c4bf0a567)

### [Laravel Testing: Assert Final Page Content After a Redirect](https://recca0120.hashnode.dev/laravel-testing-what-happens-after-a-redirect?utm_source=hashnode&utm_medium=feed)

POST requests only return a 302, hiding the final page. Use followingRedirects() to automatically follow redirects and assert on the destination page content.

1 min read · [recca0120.hashnode.dev](https://recca0120.hashnode.dev/laravel-testing-what-happens-after-a-redirect?utm_source=hashnode&utm_medium=feed)

[recca0120](https://hashnode.com/@recca0120) · [Mar 3](https://hashnode.com/posts/how-to-use-mockery-to-mock-iteratoraggregate/69a63dccb5b0a9cd95d01fd0)

### [Mock IteratorAggregate with Mockery to Fix foreach in Tests](https://recca0120.hashnode.dev/how-to-use-mockery-to-mock-iteratoraggregate?utm_source=hashnode&utm_medium=feed)

Mocking IteratorAggregate breaks foreach in PHPUnit. Return an ArrayObject from the mocked getIterator method to make foreach iterate over test data correctly.

1 min read · [recca0120.hashnode.dev](https://recca0120.hashnode.dev/how-to-use-mockery-to-mock-iteratoraggregate?utm_source=hashnode&utm_medium=feed)

[Antonio Silva](https://hashnode.com/@XxZeroxX) · [Nov 15, 2025](https://hashnode.com/posts/mastering-complex-concepts-and-proven-best-practices/6918f7126b1e844c32c900e0)

### [Mastering Complex Concepts and Proven Best Practices](https://antoniosilva.hashnode.dev/mastering-complex-concepts-and-proven-best-practices?utm_source=hashnode&utm_medium=feed)

Deep Dive into Advanced Topics and Key Practices

6 min read · [antoniosilva.hashnode.dev](https://antoniosilva.hashnode.dev/mastering-complex-concepts-and-proven-best-practices?utm_source=hashnode&utm_medium=feed)

[Antonio Silva](https://hashnode.com/@XxZeroxX) · [Nov 8, 2025](https://hashnode.com/posts/understanding-test-doubles-an-introduction-to-mocks-and-stubs/690fae611f9cd7991fa03afd)

### [Understanding Test Doubles: An Introduction to Mocks and Stubs](https://antoniosilva.hashnode.dev/understanding-test-doubles-an-introduction-to-mocks-and-stubs?utm_source=hashnode&utm_medium=feed)

Exploring the Basics of Test Doubles: Mocks and Stubs

6 min read · [antoniosilva.hashnode.dev](https://antoniosilva.hashnode.dev/understanding-test-doubles-an-introduction-to-mocks-and-stubs?utm_source=hashnode&utm_medium=feed)
