PHPackages                             staabm/phpunit-cross-os - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. staabm/phpunit-cross-os

AbandonedArchivedLibrary[Testing &amp; Quality](/categories/testing)

staabm/phpunit-cross-os
=======================

0.2.3(4y ago)11141[6 PRs](https://github.com/staabm/phpunit-cross-os/pulls)MITPHPPHP ^7.4 || ^8.0

Since Nov 29Pushed 3y ago1 watchersCompare

[ Source](https://github.com/staabm/phpunit-cross-os)[ Packagist](https://packagist.org/packages/staabm/phpunit-cross-os)[ GitHub Sponsors](https://github.com/staabm)[ RSS](/packages/staabm-phpunit-cross-os/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (6)Versions (12)Used By (0)

PHPUnit Tools to ease cross operating system Testing
====================================================

[](#phpunit-tools-to-ease-cross-operating-system-testing)

non-invasive method
-------------------

[](#non-invasive-method)

A method which makes cross-os assertions obvious.

### make `assertEquals*` comparisons end-of-line (aka `PHP_EOL`) character agnostic

[](#make-assertequals-comparisons-end-of-line-aka-php_eol-character-agnostic)

Make use of [`CrossOsAgnosticComparator`](https://github.com/staabm/phpunit-cross-os/blob/main/lib/Comparator/CrossOsAgnosticComparator.php) to make your regular `assert*`-calls aware of [`EolAgnosticString`](https://github.com/staabm/phpunit-cross-os/blob/main/lib/Comparator/EolAgnosticString.php) as a expected type.

```
use SebastianBergmann\Comparator\Factory;
use staabm\PHPUnitCrossOs\Comparator\CrossOsAgnosticComparator;
use staabm\PHPUnitCrossOs\Comparator\EolAgnosticString;

final class MyTestCase extends TestCase {

    /**
     * @var CrossOsAgnosticComparator
     */
    private $comparator;

    public function setUp(): void
    {
        $this->comparator = new CrossOsAgnosticComparator();

        $factory = Factory::getInstance();
        $factory->register($this->comparator);
    }

    public function tearDown(): void
    {
        $factory = Factory::getInstance();
        $factory->unregister($this->comparator);
    }

    public function testStringsAreEqual() {
        // this assertion will be considered successfull
        self::assertEquals(new EolAgnosticString("hello\nworld"), "hello\r\nworld");
        // works also for assertEquals* variants
        self::assertEqualsIgnoringCase(new EolAgnosticString("hello\nworld"), "hello\r\nWORLD");
    }

}
```

### make `assertEquals*` comparisons directory-separator (aka `DIRECTORY_SEPARATOR`) character agnostic

[](#make-assertequals-comparisons-directory-separator-aka-directory_separator-character-agnostic)

Make use of [`CrossOsAgnosticComparator`](https://github.com/staabm/phpunit-cross-os/blob/main/lib/Comparator/CrossOsAgnosticComparator.php) to make your regular `assert*`-calls aware of [`DirSeparatorAgnosticString`](https://github.com/staabm/phpunit-cross-os/blob/main/lib/Comparator/DirSeparatorAgnosticString.php) as a expected type.

```
use SebastianBergmann\Comparator\Factory;
use staabm\PHPUnitCrossOs\Comparator\CrossOsAgnosticComparator;
use staabm\PHPUnitCrossOs\Comparator\DirSeparatorAgnosticString;

final class MyTestCase extends TestCase {

    /**
     * @var CrossOsAgnosticComparator
     */
    private $comparator;

    public function setUp(): void
    {
        $this->comparator = new CrossOsAgnosticComparator();

        $factory = Factory::getInstance();
        $factory->register($this->comparator);
    }

    public function tearDown(): void
    {
        $factory = Factory::getInstance();
        $factory->unregister($this->comparator);
    }

    public function testStringsAreEqual() {
        // this assertion will be considered successfull
        self::assertEquals(new DirSeparatorAgnosticString("hello\\world"), "hello/world");
        // works also for assertEquals* variants
        self::assertEqualsIgnoringCase(new DirSeparatorAgnosticString("hello\\world"), "hello/WORLD");
    }

}
```

### make `assertEquals*` comparisons cross os agnostic

[](#make-assertequals-comparisons-cross-os-agnostic)

Make use of [`CrossOsAgnosticComparator`](https://github.com/staabm/phpunit-cross-os/blob/main/lib/Comparator/CrossOsAgnosticComparator.php) to make your regular `assert*`-calls aware of [`CrossOsAgnosticString`](https://github.com/staabm/phpunit-cross-os/blob/main/lib/Comparator/CrossOsAgnosticString.php) as a expected type.

```
use SebastianBergmann\Comparator\Factory;
use staabm\PHPUnitCrossOs\Comparator\CrossOsAgnosticComparator;
use staabm\PHPUnitCrossOs\Comparator\CrossOsAgnosticString;

final class MyTestCase extends TestCase {

    /**
     * @var CrossOsAgnosticComparator
     */
    private $comparator;

    public function setUp(): void
    {
        $this->comparator = new CrossOsAgnosticComparator();

        $factory = Factory::getInstance();
        $factory->register($this->comparator);
    }

    public function tearDown(): void
    {
        $factory = Factory::getInstance();
        $factory->unregister($this->comparator);
    }

    public function testStringsAreEqual() {
        // this assertion will be considered successfull
        self::assertEquals(new CrossOsAgnosticString("hello\\world"), "hello/world");
        // works also for assertEquals* variants
        self::assertEqualsIgnoringCase(new CrossOsAgnosticString("hello\\world"), "hello/WORLD");
    }

}
```

invasive method
---------------

[](#invasive-method)

A method to test cross-os related stuff using php builtin assertions. You may not like it, because it makes your test feels kind of magical as your `assertEquals()` calls will behave differently based on the given parameters.

### make `assertEquals*` comparisons end-of-line (aka `PHP_EOL`) character agnostic

[](#make-assertequals-comparisons-end-of-line-aka-php_eol-character-agnostic-1)

Make use of [`EolAgnosticStringComparator`](https://github.com/staabm/phpunit-cross-os/blob/main/lib/Comparator/EolAgnosticStringComparator.php) to make your regular `assert*`-calls succeed even if the compared string differ in end-of-line characters:

```
use SebastianBergmann\Comparator\Factory;
use staabm\PHPUnitCrossOs\Comparator\EolAgnosticStringComparator;

final class MyTestCase extends TestCase {

    /**
     * @var EolAgnosticStringComparator
     */
    private $comparator;

    public function setUp(): void
    {
        $this->comparator = new EolAgnosticStringComparator();

        $factory = Factory::getInstance();
        $factory->register($this->comparator);
    }

    public function tearDown(): void
    {
        $factory = Factory::getInstance();
        $factory->unregister($this->comparator);
    }

    public function testStringsAreEqual() {
        // this assertion will be considered successfull
        self::assertEquals("hello\nworld", "hello\r\nworld");
        // works also for assertEquals* variants
        self::assertEqualsIgnoringCase("hello\nworld", "hello\r\nWORLD");
    }

}
```

### make `assertEquals*` comparisons directory-separator (aka `DIRECTORY_SEPARATOR`) character agnostic

[](#make-assertequals-comparisons-directory-separator-aka-directory_separator-character-agnostic-1)

Make use of [`DirSeparatorAgnosticStringComparator.php`](https://github.com/staabm/phpunit-cross-os/blob/main/lib/Comparator/DirSeparatorAgnosticStringComparator.php.php) to make your regular `assert*`-calls succeed even if the compared string differ in directory-separation characters:

```
use SebastianBergmann\Comparator\Factory;
use staabm\PHPUnitCrossOs\Comparator\DirSeparatorAgnosticStringComparator;

final class MyTestCase extends TestCase {

    /**
     * @var DirSeparatorAgnosticStringComparator
     */
    private $comparator;

    public function setUp(): void
    {
        $this->comparator = new DirSeparatorAgnosticStringComparator();

        $factory = Factory::getInstance();
        $factory->register($this->comparator);
    }

    public function tearDown(): void
    {
        $factory = Factory::getInstance();
        $factory->unregister($this->comparator);
    }

    public function testStringsAreEqual() {
        // this assertion will be considered successfull
        self::assertEquals("hello\\world", "hello/world");
        // works also for assertEquals* variants
        self::assertEqualsIgnoringCase("hello\\world", "hello/WORLD");
    }

}
```

### make `assertEquals*` comparisons cross os agnostic

[](#make-assertequals-comparisons-cross-os-agnostic-1)

Make use of [`CrossOsAgnosticStringComparatorFunctionalTest.php`](https://github.com/staabm/phpunit-cross-os/blob/main/lib/Comparator/CrossOsAgnosticStringComparatorFunctionalTest.php.php) to make your regular `assert*`-calls succeed even if the compared string differ in directory-separation and/or end-of-line characters:

`CrossOsAgnosticStringComparatorFunctionalTest` essentially provides all features of `DirSeparatorAgnosticStringComparator` and `EolAgnosticStringComparator` combined in a single class.

```
use SebastianBergmann\Comparator\Factory;
use staabm\PHPUnitCrossOs\Comparator\CrossOsAgnosticStringComparatorFunctionalTest;

final class MyTestCase extends TestCase {

    /**
     * @var CrossOsAgnosticStringComparatorFunctionalTest
     */
    private $comparator;

    public function setUp(): void
    {
        $this->comparator = new CrossOsAgnosticStringComparatorFunctionalTest();

        $factory = Factory::getInstance();
        $factory->register($this->comparator);
    }

    public function tearDown(): void
    {
        $factory = Factory::getInstance();
        $factory->unregister($this->comparator);
    }

    public function testStringsAreEqual() {
        // this assertion will be considered successfull
        self::assertEquals("hello\\world\n", "hello/world\r\n");
        // works also for assertEquals* variants
        self::assertEqualsIgnoringCase("hello\\world\r\n", "hello/WORLD\n");
    }

}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

5

Last Release

1611d ago

PHP version history (2 changes)0.1PHP ^8.0

0.2.1PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/99d4e5e5fa8fb7d0782de39b43c558953d0a5881a7ba596b90ed9c312db8c4d9?d=identicon)[staabm](/maintainers/staabm)

---

Top Contributors

[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (13 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")[![clxmstaab](https://avatars.githubusercontent.com/u/47448731?v=4)](https://github.com/clxmstaab "clxmstaab (2 commits)")[![fbecker-complex](https://avatars.githubusercontent.com/u/71324952?v=4)](https://github.com/fbecker-complex "fbecker-complex (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/staabm-phpunit-cross-os/health.svg)

```
[![Health](https://phpackages.com/badges/staabm-phpunit-cross-os/health.svg)](https://phpackages.com/packages/staabm-phpunit-cross-os)
```

###  Alternatives

[phpunit/phpunit

The PHP Unit Testing framework.

20.0k910.7M134.8k](/packages/phpunit-phpunit)[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[codeception/codeception

All-in-one PHP Testing Framework

4.9k86.2M2.9k](/packages/codeception-codeception)[nelmio/alice

Expressive fixtures generator

2.5k43.4M133](/packages/nelmio-alice)[phake/phake

The Phake mock testing library

4758.0M324](/packages/phake-phake)[bovigo/assert

Provides assertions for unit tests.

13707.7k18](/packages/bovigo-assert)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
