1. Go to this page and download the library: Download staabm/phpunit-cross-os library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
staabm / phpunit-cross-os example snippets
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");
}
}
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");
}
}
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");
}
}
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");
}
}
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");
}
}
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");
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.