Initial Commit
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
trait T3194
|
||||
{
|
||||
public function doSomethingElse(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
final class C3194
|
||||
{
|
||||
use T3194;
|
||||
|
||||
public function doSomething(): bool
|
||||
{
|
||||
return $this->doSomethingElse();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers C3194
|
||||
*/
|
||||
final class Test3194 extends TestCase
|
||||
{
|
||||
public function testOne(): void
|
||||
{
|
||||
$o = new C;
|
||||
|
||||
$this->assertTrue($o->doSomething());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
abstract class AbstractMockTestClass implements MockTestInterface
|
||||
{
|
||||
abstract public function doSomething();
|
||||
|
||||
public function returnAnything()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class AbstractTest extends TestCase
|
||||
{
|
||||
public function testOne(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
trait AbstractTrait
|
||||
{
|
||||
abstract public function doSomething();
|
||||
|
||||
public function mockableMethod()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function anotherMockableMethod()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
interface AnInterface
|
||||
{
|
||||
public function doSomething();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
interface AnInterfaceWithReturnType
|
||||
{
|
||||
public function returnAnArray(): array;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
interface AnotherInterface
|
||||
{
|
||||
public function doSomethingElse();
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class ArrayAccessible implements ArrayAccess, IteratorAggregate
|
||||
{
|
||||
private $array;
|
||||
|
||||
public function __construct(array $array = [])
|
||||
{
|
||||
$this->array = $array;
|
||||
}
|
||||
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return \array_key_exists($offset, $this->array);
|
||||
}
|
||||
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return $this->array[$offset];
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value): void
|
||||
{
|
||||
if (null === $offset) {
|
||||
$this->array[] = $value;
|
||||
} else {
|
||||
$this->array[$offset] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function offsetUnset($offset): void
|
||||
{
|
||||
unset($this->array[$offset]);
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->array);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class AssertionExample
|
||||
{
|
||||
public function doSomething(): void
|
||||
{
|
||||
\assert(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AssertionExampleTest extends TestCase
|
||||
{
|
||||
public function testOne(): void
|
||||
{
|
||||
$e = new AssertionExample;
|
||||
|
||||
$e->doSomething();
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* An author.
|
||||
*/
|
||||
class Author
|
||||
{
|
||||
// the order of properties is important for testing the cycle!
|
||||
public $books = [];
|
||||
|
||||
private $name = '';
|
||||
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
class BankAccountException extends RuntimeException
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* A bank account.
|
||||
*/
|
||||
class BankAccount
|
||||
{
|
||||
/**
|
||||
* The bank account's balance.
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $balance = 0;
|
||||
|
||||
/**
|
||||
* Returns the bank account's balance.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getBalance()
|
||||
{
|
||||
return $this->balance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deposits an amount of money to the bank account.
|
||||
*
|
||||
* @param float $balance
|
||||
*
|
||||
* @throws BankAccountException
|
||||
*/
|
||||
public function depositMoney($balance)
|
||||
{
|
||||
$this->setBalance($this->getBalance() + $balance);
|
||||
|
||||
return $this->getBalance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Withdraws an amount of money from the bank account.
|
||||
*
|
||||
* @param float $balance
|
||||
*
|
||||
* @throws BankAccountException
|
||||
*/
|
||||
public function withdrawMoney($balance)
|
||||
{
|
||||
$this->setBalance($this->getBalance() - $balance);
|
||||
|
||||
return $this->getBalance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bank account's balance.
|
||||
*
|
||||
* @param float $balance
|
||||
*
|
||||
* @throws BankAccountException
|
||||
*/
|
||||
protected function setBalance($balance): void
|
||||
{
|
||||
if ($balance >= 0) {
|
||||
$this->balance = $balance;
|
||||
} else {
|
||||
throw new BankAccountException;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Tests for the BankAccount class.
|
||||
*/
|
||||
class BankAccountTest extends TestCase
|
||||
{
|
||||
protected $ba;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->ba = new BankAccount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers BankAccount::getBalance
|
||||
* @group balanceIsInitiallyZero
|
||||
* @group specification
|
||||
*/
|
||||
public function testBalanceIsInitiallyZero(): void
|
||||
{
|
||||
/* @Given a fresh bank account */
|
||||
$ba = new BankAccount;
|
||||
|
||||
/* @When I ask it for its balance */
|
||||
$balance = $ba->getBalance();
|
||||
|
||||
/* @Then I should get 0 */
|
||||
$this->assertEquals(0, $balance);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers BankAccount::withdrawMoney
|
||||
* @group balanceCannotBecomeNegative
|
||||
* @group specification
|
||||
*/
|
||||
public function testBalanceCannotBecomeNegative(): void
|
||||
{
|
||||
try {
|
||||
$this->ba->withdrawMoney(1);
|
||||
} catch (BankAccountException $e) {
|
||||
$this->assertEquals(0, $this->ba->getBalance());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers BankAccount::depositMoney
|
||||
* @group balanceCannotBecomeNegative
|
||||
* @group specification
|
||||
*/
|
||||
public function testBalanceCannotBecomeNegative2(): void
|
||||
{
|
||||
try {
|
||||
$this->ba->depositMoney(-1);
|
||||
} catch (BankAccountException $e) {
|
||||
$this->assertEquals(0, $this->ba->getBalance());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
/*
|
||||
* @covers BankAccount::getBalance
|
||||
* @covers BankAccount::depositMoney
|
||||
* @covers BankAccount::withdrawMoney
|
||||
* @group balanceCannotBecomeNegative
|
||||
*/
|
||||
/*
|
||||
public function testDepositingAndWithdrawingMoneyWorks()
|
||||
{
|
||||
$this->assertEquals(0, $this->ba->getBalance());
|
||||
$this->ba->depositMoney(1);
|
||||
$this->assertEquals(1, $this->ba->getBalance());
|
||||
$this->ba->withdrawMoney(1);
|
||||
$this->assertEquals(0, $this->ba->getBalance());
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Tests for the BankAccount class.
|
||||
*/
|
||||
class BankAccountWithCustomExtensionTest extends TestCase
|
||||
{
|
||||
protected $ba;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->ba = new BankAccount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers BankAccount::getBalance
|
||||
* @group balanceIsInitiallyZero
|
||||
* @group specification
|
||||
*/
|
||||
public function testBalanceIsInitiallyZero(): void
|
||||
{
|
||||
$this->assertEquals(0, $this->ba->getBalance());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers BankAccount::withdrawMoney
|
||||
* @group balanceCannotBecomeNegative
|
||||
* @group specification
|
||||
*/
|
||||
public function testBalanceCannotBecomeNegative(): void
|
||||
{
|
||||
try {
|
||||
$this->ba->withdrawMoney(1);
|
||||
} catch (BankAccountException $e) {
|
||||
$this->assertEquals(0, $this->ba->getBalance());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers BankAccount::depositMoney
|
||||
* @group balanceCannotBecomeNegative
|
||||
* @group specification
|
||||
*/
|
||||
public function testBalanceCannotBecomeNegative2(): void
|
||||
{
|
||||
try {
|
||||
$this->ba->depositMoney(-1);
|
||||
} catch (BankAccountException $e) {
|
||||
$this->assertEquals(0, $this->ba->getBalance());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
/*
|
||||
* @covers BankAccount::getBalance
|
||||
* @covers BankAccount::depositMoney
|
||||
* @covers BankAccount::withdrawMoney
|
||||
* @group balanceCannotBecomeNegative
|
||||
*/
|
||||
/*
|
||||
public function testDepositingAndWithdrawingMoneyWorks()
|
||||
{
|
||||
$this->assertEquals(0, $this->ba->getBalance());
|
||||
$this->ba->depositMoney(1);
|
||||
$this->assertEquals(1, $this->ba->getBalance());
|
||||
$this->ba->withdrawMoney(1);
|
||||
$this->assertEquals(0, $this->ba->getBalance());
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BankAccountTest extends TestCase
|
||||
{
|
||||
private $ba;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->ba = new BankAccount;
|
||||
}
|
||||
|
||||
public function testBalanceIsInitiallyZero(): void
|
||||
{
|
||||
$ba = new BankAccount;
|
||||
|
||||
$balance = $ba->getBalance();
|
||||
|
||||
$this->assertEquals(0, $balance);
|
||||
}
|
||||
|
||||
public function testBalanceCannotBecomeNegative(): void
|
||||
{
|
||||
try {
|
||||
$this->ba->withdrawMoney(1);
|
||||
} catch (BankAccountException $e) {
|
||||
$this->assertEquals(0, $this->ba->getBalance());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testBalanceCannotBecomeNegative2(): void
|
||||
{
|
||||
try {
|
||||
$this->ba->depositMoney(-1);
|
||||
} catch (BankAccountException $e) {
|
||||
$this->assertEquals(0, $this->ba->getBalance());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class Bar
|
||||
{
|
||||
public function doSomethingElse()
|
||||
{
|
||||
return 'result';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BeforeAndAfterTest extends TestCase
|
||||
{
|
||||
public static $beforeWasRun;
|
||||
|
||||
public static $afterWasRun;
|
||||
|
||||
public static function resetProperties(): void
|
||||
{
|
||||
self::$beforeWasRun = 0;
|
||||
self::$afterWasRun = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @before
|
||||
*/
|
||||
public function initialSetup(): void
|
||||
{
|
||||
self::$beforeWasRun++;
|
||||
}
|
||||
|
||||
/**
|
||||
* @after
|
||||
*/
|
||||
public function finalTeardown(): void
|
||||
{
|
||||
self::$afterWasRun++;
|
||||
}
|
||||
|
||||
public function test1(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function test2(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BeforeClassAndAfterClassTest extends TestCase
|
||||
{
|
||||
public static $beforeClassWasRun = 0;
|
||||
|
||||
public static $afterClassWasRun = 0;
|
||||
|
||||
public static function resetProperties(): void
|
||||
{
|
||||
self::$beforeClassWasRun = 0;
|
||||
self::$afterClassWasRun = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @beforeClass
|
||||
*/
|
||||
public static function initialClassSetup(): void
|
||||
{
|
||||
self::$beforeClassWasRun++;
|
||||
}
|
||||
|
||||
/**
|
||||
* @afterClass
|
||||
*/
|
||||
public static function finalClassTeardown(): void
|
||||
{
|
||||
self::$afterClassWasRun++;
|
||||
}
|
||||
|
||||
public function test1(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function test2(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class BeforeClassWithOnlyDataProviderTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public static $setUpBeforeClassWasCalled;
|
||||
|
||||
public static $beforeClassWasCalled;
|
||||
|
||||
public static function resetProperties(): void
|
||||
{
|
||||
self::$setUpBeforeClassWasCalled = false;
|
||||
self::$beforeClassWasCalled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @beforeClass
|
||||
*/
|
||||
public static function someAnnotatedSetupMethod(): void
|
||||
{
|
||||
self::$beforeClassWasCalled = true;
|
||||
}
|
||||
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
self::$setUpBeforeClassWasCalled = true;
|
||||
}
|
||||
|
||||
public function dummyProvider()
|
||||
{
|
||||
return [[1]];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dummyProvider
|
||||
* delete annotation to fail test case
|
||||
*/
|
||||
public function testDummy(): void
|
||||
{
|
||||
$this->assertFalse(false);
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A book.
|
||||
*/
|
||||
class Book
|
||||
{
|
||||
// the order of properties is important for testing the cycle!
|
||||
public $author;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class Calculator
|
||||
{
|
||||
/**
|
||||
* @assert (0, 0) == 0
|
||||
* @assert (0, 1) == 1
|
||||
* @assert (1, 0) == 1
|
||||
* @assert (1, 1) == 2
|
||||
*/
|
||||
public function add($a, $b)
|
||||
{
|
||||
return $a + $b;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ChangeCurrentWorkingDirectoryTest extends TestCase
|
||||
{
|
||||
public function testSomethingThatChangesTheCwd(): void
|
||||
{
|
||||
\chdir('../');
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class ClassThatImplementsSerializable implements Serializable
|
||||
{
|
||||
public function serialize()
|
||||
{
|
||||
return \get_object_vars($this);
|
||||
}
|
||||
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
foreach (\unserialize($serialized) as $key => $value) {
|
||||
$this->{$key} = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class ClassWithAllPossibleReturnTypes
|
||||
{
|
||||
public function methodWithNoReturnTypeDeclaration()
|
||||
{
|
||||
}
|
||||
|
||||
public function methodWithVoidReturnTypeDeclaration(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function methodWithStringReturnTypeDeclaration(): string
|
||||
{
|
||||
return 'string';
|
||||
}
|
||||
|
||||
public function methodWithFloatReturnTypeDeclaration(): float
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
public function methodWithIntReturnTypeDeclaration(): int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function methodWithBoolReturnTypeDeclaration(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function methodWithArrayReturnTypeDeclaration(): array
|
||||
{
|
||||
return ['string'];
|
||||
}
|
||||
|
||||
public function methodWithTraversableReturnTypeDeclaration(): Traversable
|
||||
{
|
||||
return new ArrayIterator(['string']);
|
||||
}
|
||||
|
||||
public function methodWithGeneratorReturnTypeDeclaration(): Generator
|
||||
{
|
||||
yield 1;
|
||||
}
|
||||
|
||||
public function methodWithObjectReturnTypeDeclaration(): object
|
||||
{
|
||||
return new Exception;
|
||||
}
|
||||
|
||||
public function methodWithClassReturnTypeDeclaration(): stdClass
|
||||
{
|
||||
return new stdClass;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class ParentClassWithPrivateAttributes
|
||||
{
|
||||
private static $privateStaticParentAttribute = 'foo';
|
||||
|
||||
private $privateParentAttribute = 'bar';
|
||||
}
|
||||
|
||||
class ParentClassWithProtectedAttributes extends ParentClassWithPrivateAttributes
|
||||
{
|
||||
protected static $protectedStaticParentAttribute = 'foo';
|
||||
|
||||
protected $protectedParentAttribute = 'bar';
|
||||
}
|
||||
|
||||
class ClassWithNonPublicAttributes extends ParentClassWithProtectedAttributes
|
||||
{
|
||||
public static $publicStaticAttribute = 'foo';
|
||||
|
||||
protected static $protectedStaticAttribute = 'bar';
|
||||
|
||||
protected static $privateStaticAttribute = 'baz';
|
||||
|
||||
public $publicAttribute = 'foo';
|
||||
|
||||
public $foo = 1;
|
||||
|
||||
public $bar = 2;
|
||||
|
||||
public $publicArray = ['foo'];
|
||||
|
||||
protected $protectedAttribute = 'bar';
|
||||
|
||||
protected $privateAttribute = 'baz';
|
||||
|
||||
protected $protectedArray = ['bar'];
|
||||
|
||||
protected $privateArray = ['baz'];
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class ClassWithScalarTypeDeclarations
|
||||
{
|
||||
public function foo(string $string, int $int): void
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class ClassWithSelfTypeHint
|
||||
{
|
||||
public function foo(self $foo)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class ClassWithStaticMethod
|
||||
{
|
||||
public static function staticMethod()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A class with a __toString() method.
|
||||
*/
|
||||
class ClassWithToString
|
||||
{
|
||||
public function __toString()
|
||||
{
|
||||
return 'string representation';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A class with a method that takes a variadic argument.
|
||||
*/
|
||||
class ClassWithVariadicArgumentMethod
|
||||
{
|
||||
public function foo(...$args)
|
||||
{
|
||||
return $args;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ClonedDependencyTest extends TestCase
|
||||
{
|
||||
private static $dependency;
|
||||
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
self::$dependency = new stdClass;
|
||||
}
|
||||
|
||||
public function testOne()
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
|
||||
return self::$dependency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testOne
|
||||
*/
|
||||
public function testTwo($dependency): void
|
||||
{
|
||||
$this->assertSame(self::$dependency, $dependency);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends !clone testOne
|
||||
*/
|
||||
public function testThree($dependency): void
|
||||
{
|
||||
$this->assertSame(self::$dependency, $dependency);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends clone testOne
|
||||
*/
|
||||
public function testFour($dependency): void
|
||||
{
|
||||
$this->assertNotSame(self::$dependency, $dependency);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends !shallowClone testOne
|
||||
*/
|
||||
public function testFive($dependency): void
|
||||
{
|
||||
$this->assertSame(self::$dependency, $dependency);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends shallowClone testOne
|
||||
*/
|
||||
public function testSix($dependency): void
|
||||
{
|
||||
$this->assertNotSame(self::$dependency, $dependency);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class ConcreteWithMyCustomExtensionTest extends AbstractTest
|
||||
{
|
||||
public function testTwo(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class ConcreteTest extends AbstractTest
|
||||
{
|
||||
public function testTwo(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\Constraint\Constraint;
|
||||
|
||||
final class CountConstraint extends Constraint
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $count;
|
||||
|
||||
public static function fromCount(int $count): self
|
||||
{
|
||||
$instance = new self();
|
||||
|
||||
$instance->count = $count;
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function matches($other): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function toString(): string
|
||||
{
|
||||
return \sprintf(
|
||||
'is accepted by %s',
|
||||
self::class
|
||||
);
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return $this->count;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoverageClassExtendedTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass<extended>
|
||||
*/
|
||||
public function testSomething(): void
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoverageClassTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass
|
||||
*/
|
||||
public function testSomething(): void
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @coversNothing
|
||||
*/
|
||||
class CoverageCoversOverridesCoversNothingTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::publicMethod
|
||||
*/
|
||||
public function testSomething(): void
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoverageFunctionParenthesesTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::globalFunction()
|
||||
*/
|
||||
public function testSomething(): void
|
||||
{
|
||||
globalFunction();
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoverageFunctionParenthesesWhitespaceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::globalFunction ( )
|
||||
*/
|
||||
public function testSomething(): void
|
||||
{
|
||||
globalFunction();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoverageFunctionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::globalFunction
|
||||
*/
|
||||
public function testSomething(): void
|
||||
{
|
||||
globalFunction();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoverageMethodOneLineAnnotationTest extends TestCase
|
||||
{
|
||||
/** @covers CoveredClass::publicMethod */
|
||||
public function testSomething(): void
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoverageMethodParenthesesTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::publicMethod()
|
||||
*/
|
||||
public function testSomething(): void
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoverageMethodParenthesesWhitespaceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::publicMethod ( )
|
||||
*/
|
||||
public function testSomething(): void
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoverageMethodTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::publicMethod
|
||||
*/
|
||||
public function testSomething(): void
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoverageNamespacedFunctionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers foo\func()
|
||||
*/
|
||||
public function testFunc(): void
|
||||
{
|
||||
foo\func();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoverageNoneTest extends TestCase
|
||||
{
|
||||
public function testSomething(): void
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoverageNotPrivateTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::<!private>
|
||||
*/
|
||||
public function testSomething(): void
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoverageNotProtectedTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::<!protected>
|
||||
*/
|
||||
public function testSomething(): void
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoverageNotPublicTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::<!public>
|
||||
*/
|
||||
public function testSomething(): void
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoverageNothingTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::publicMethod
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testSomething(): void
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoveragePrivateTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::<private>
|
||||
*/
|
||||
public function testSomething(): void
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoverageProtectedTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::<protected>
|
||||
*/
|
||||
public function testSomething(): void
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoveragePublicTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers CoveredClass::<public>
|
||||
*/
|
||||
public function testSomething(): void
|
||||
{
|
||||
$o = new CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \NamespaceOne
|
||||
* @coversDefaultClass \AnotherDefault\Name\Space\Does\Not\Work
|
||||
*/
|
||||
class CoverageTwoDefaultClassAnnotations
|
||||
{
|
||||
/**
|
||||
* @covers Foo\CoveredClass::<public>
|
||||
*/
|
||||
public function testSomething(): void
|
||||
{
|
||||
$o = new Foo\CoveredClass;
|
||||
$o->publicMethod();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class CoveredParentClass
|
||||
{
|
||||
public function publicMethod(): void
|
||||
{
|
||||
$this->protectedMethod();
|
||||
}
|
||||
|
||||
protected function protectedMethod(): void
|
||||
{
|
||||
$this->privateMethod();
|
||||
}
|
||||
|
||||
private function privateMethod(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class CoveredClass extends CoveredParentClass
|
||||
{
|
||||
public function publicMethod(): void
|
||||
{
|
||||
parent::publicMethod();
|
||||
$this->protectedMethod();
|
||||
}
|
||||
|
||||
protected function protectedMethod(): void
|
||||
{
|
||||
parent::protectedMethod();
|
||||
$this->privateMethod();
|
||||
}
|
||||
|
||||
private function privateMethod(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
function globalFunction(): void
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\TextUI\ResultPrinter;
|
||||
|
||||
class CustomPrinter extends ResultPrinter
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DataProviderDebugTest extends TestCase
|
||||
{
|
||||
public static function provider()
|
||||
{
|
||||
$obj2 = new \stdClass();
|
||||
$obj2->foo = 'bar';
|
||||
|
||||
$obj3 = (object) [1, 2, "Test\r\n", 4, 5, 6, 7, 8];
|
||||
|
||||
$obj = new \stdClass();
|
||||
//@codingStandardsIgnoreStart
|
||||
$obj->null = null;
|
||||
//@codingStandardsIgnoreEnd
|
||||
$obj->boolean = true;
|
||||
$obj->integer = 1;
|
||||
$obj->double = 1.2;
|
||||
$obj->string = '1';
|
||||
$obj->text = "this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext";
|
||||
$obj->object = $obj2;
|
||||
$obj->objectagain = $obj2;
|
||||
$obj->array = ['foo' => 'bar'];
|
||||
$obj->self = $obj;
|
||||
|
||||
$storage = new \SplObjectStorage();
|
||||
$storage->attach($obj2);
|
||||
$storage->foo = $obj;
|
||||
|
||||
return [
|
||||
[null, true, 1, 1.0],
|
||||
[1.2, \fopen('php://memory', 'r'), '1'],
|
||||
[[[1, 2, 3], [3, 4, 5]]],
|
||||
// \n\r and \r is converted to \n
|
||||
["this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext"],
|
||||
[new \stdClass(), $obj, [], $storage, $obj3],
|
||||
[\chr(0) . \chr(1) . \chr(2) . \chr(3) . \chr(4) . \chr(5), \implode('', \array_map('chr', \range(0x0e, 0x1f)))],
|
||||
[\chr(0x00) . \chr(0x09)],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provider
|
||||
*/
|
||||
public function testProvider(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class DataProviderDependencyTest extends PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testReference(): void
|
||||
{
|
||||
$this->markTestSkipped('This test should be skipped.');
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://github.com/sebastianbergmann/phpunit/issues/1896
|
||||
* @depends testReference
|
||||
* @dataProvider provider
|
||||
*/
|
||||
public function testDependency($param): void
|
||||
{
|
||||
}
|
||||
|
||||
public function provider()
|
||||
{
|
||||
$this->markTestSkipped('Any test with this data provider should be skipped.');
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DataProviderFilterTest extends TestCase
|
||||
{
|
||||
public static function truthProvider()
|
||||
{
|
||||
return [
|
||||
[true],
|
||||
[true],
|
||||
[true],
|
||||
[true],
|
||||
];
|
||||
}
|
||||
|
||||
public static function falseProvider()
|
||||
{
|
||||
return [
|
||||
'false test' => [false],
|
||||
'false test 2' => [false],
|
||||
'other false test' => [false],
|
||||
'other false test2'=> [false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider truthProvider
|
||||
*/
|
||||
public function testTrue($truth): void
|
||||
{
|
||||
$this->assertTrue($truth);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider falseProvider
|
||||
*/
|
||||
public function testFalse($false): void
|
||||
{
|
||||
$this->assertFalse($false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DataProviderIncompleteTest extends TestCase
|
||||
{
|
||||
public static function providerMethod()
|
||||
{
|
||||
return [
|
||||
[0, 0, 0],
|
||||
[0, 1, 1],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider incompleteTestProviderMethod
|
||||
*/
|
||||
public function testIncomplete($a, $b, $c): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerMethod
|
||||
*/
|
||||
public function testAdd($a, $b, $c): void
|
||||
{
|
||||
$this->assertEquals($c, $a + $b);
|
||||
}
|
||||
|
||||
public function incompleteTestProviderMethod()
|
||||
{
|
||||
$this->markTestIncomplete('incomplete');
|
||||
|
||||
return [
|
||||
[0, 0, 0],
|
||||
[0, 1, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Foo\DataProviderIssue2833;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FirstTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provide
|
||||
*/
|
||||
public function testFirst($x): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function provide()
|
||||
{
|
||||
SecondTest::DUMMY;
|
||||
|
||||
return [[true]];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Foo\DataProviderIssue2833;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SecondTest extends TestCase
|
||||
{
|
||||
const DUMMY = 'dummy';
|
||||
|
||||
public function testSecond(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit>
|
||||
<testsuites>
|
||||
<testsuite name="Test Suite">
|
||||
<directory>./tests/</directory>
|
||||
<directory>./tests/*/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
vendor/phpunit/phpunit/tests/_files/DataProviderIssue2859/tests/another/TestWithDataProviderTest.php
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Foo\DataProviderIssue2859;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TestWithDataProviderTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provide
|
||||
*/
|
||||
public function testFirst($x): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function provide()
|
||||
{
|
||||
return [[true]];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Foo\DataProviderIssue2922;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @group foo
|
||||
*/
|
||||
class FirstTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provide
|
||||
*/
|
||||
public function testFirst($x): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function provide(): void
|
||||
{
|
||||
throw new \Exception();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Foo\DataProviderIssue2922;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
// the name of the class cannot match file name - if they match all is fine
|
||||
class SecondHelloWorldTest extends TestCase
|
||||
{
|
||||
public function testSecond(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DataProviderSkippedTest extends TestCase
|
||||
{
|
||||
public static function providerMethod()
|
||||
{
|
||||
return [
|
||||
[0, 0, 0],
|
||||
[0, 1, 1],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider skippedTestProviderMethod
|
||||
*/
|
||||
public function testSkipped($a, $b, $c): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerMethod
|
||||
*/
|
||||
public function testAdd($a, $b, $c): void
|
||||
{
|
||||
$this->assertEquals($c, $a + $b);
|
||||
}
|
||||
|
||||
public function skippedTestProviderMethod()
|
||||
{
|
||||
$this->markTestSkipped('skipped');
|
||||
|
||||
return [
|
||||
[0, 0, 0],
|
||||
[0, 1, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DataProviderTest extends TestCase
|
||||
{
|
||||
public static function providerMethod()
|
||||
{
|
||||
return [
|
||||
[0, 0, 0],
|
||||
[0, 1, 1],
|
||||
[1, 1, 3],
|
||||
[1, 0, 1],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerMethod
|
||||
*/
|
||||
public function testAdd($a, $b, $c): void
|
||||
{
|
||||
$this->assertEquals($c, $a + $b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DataProviderTestDoxTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provider
|
||||
* @testdox Does something with
|
||||
*/
|
||||
public function testOne(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provider
|
||||
*/
|
||||
public function testDoesSomethingElseWith(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider placeHolderprovider
|
||||
* @testdox ... $value ...
|
||||
*/
|
||||
public function testWithPlaceholders($value): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function provider()
|
||||
{
|
||||
return [
|
||||
'one' => [1],
|
||||
'two' => [2],
|
||||
];
|
||||
}
|
||||
|
||||
public function placeHolderprovider(): array
|
||||
{
|
||||
return [
|
||||
'boolean' => [true],
|
||||
'integer' => [1],
|
||||
'float' => [1.0],
|
||||
'string' => ['string'],
|
||||
'array' => [[1, 2, 3]],
|
||||
'object' => [new \stdClass],
|
||||
'stringableObject' => [new class {
|
||||
public function __toString()
|
||||
{
|
||||
return 'string';
|
||||
}
|
||||
}],
|
||||
'resource' => [\fopen(__FILE__, 'rb')],
|
||||
'null' => [null],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DependencyFailureTest extends TestCase
|
||||
{
|
||||
public function testOne(): void
|
||||
{
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testOne
|
||||
*/
|
||||
public function testTwo(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends !clone testTwo
|
||||
*/
|
||||
public function testThree(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends clone testOne
|
||||
*/
|
||||
public function testFour(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DependencySuccessTest extends TestCase
|
||||
{
|
||||
public function testOne(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testOne
|
||||
*/
|
||||
public function testTwo(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends DependencySuccessTest::testTwo
|
||||
*/
|
||||
public function testThree(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestSuite;
|
||||
|
||||
class DependencyTestSuite
|
||||
{
|
||||
public static function suite()
|
||||
{
|
||||
$suite = new TestSuite('Test Dependencies');
|
||||
|
||||
$suite->addTestSuite(DependencySuccessTest::class);
|
||||
$suite->addTestSuite(DependencyFailureTest::class);
|
||||
|
||||
return $suite;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DoNoAssertionTestCase extends TestCase
|
||||
{
|
||||
public function testNothing(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DoesNotPerformAssertionsButPerformingAssertionsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @doesNotPerformAssertions
|
||||
*/
|
||||
public function testFalseAndTrueAreStillFine(): void
|
||||
{
|
||||
$this->assertFalse(false);
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\TestResult;
|
||||
|
||||
class DoubleTestCase implements Test
|
||||
{
|
||||
protected $testCase;
|
||||
|
||||
public function __construct(TestCase $testCase)
|
||||
{
|
||||
$this->testCase = $testCase;
|
||||
}
|
||||
|
||||
public function count()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function run(TestResult $result = null): TestResult
|
||||
{
|
||||
$result->startTest($this);
|
||||
|
||||
$this->testCase->runBare();
|
||||
$this->testCase->runBare();
|
||||
|
||||
$result->endTest($this, 0);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DummyBarTest extends TestCase
|
||||
{
|
||||
public function testBarEqualsBar(): void
|
||||
{
|
||||
$this->assertEquals('Bar', 'Bar');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class DummyException extends Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DummyFooTest extends TestCase
|
||||
{
|
||||
public function testFooEqualsFoo(): void
|
||||
{
|
||||
$this->assertEquals('Foo', 'Foo');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class EmptyTestCaseTest extends TestCase
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
trait ExampleTrait
|
||||
{
|
||||
public function ohHai()
|
||||
{
|
||||
return __FUNCTION__;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExceptionInAssertPostConditionsTest extends TestCase
|
||||
{
|
||||
public $setUp = false;
|
||||
|
||||
public $assertPreConditions = false;
|
||||
|
||||
public $assertPostConditions = false;
|
||||
|
||||
public $tearDown = false;
|
||||
|
||||
public $testSomething = false;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->setUp = true;
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->tearDown = true;
|
||||
}
|
||||
|
||||
public function testSomething(): void
|
||||
{
|
||||
$this->testSomething = true;
|
||||
}
|
||||
|
||||
protected function assertPreConditions(): void
|
||||
{
|
||||
$this->assertPreConditions = true;
|
||||
}
|
||||
|
||||
protected function assertPostConditions(): void
|
||||
{
|
||||
$this->assertPostConditions = true;
|
||||
|
||||
throw new Exception;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExceptionInAssertPreConditionsTest extends TestCase
|
||||
{
|
||||
public $setUp = false;
|
||||
|
||||
public $assertPreConditions = false;
|
||||
|
||||
public $assertPostConditions = false;
|
||||
|
||||
public $tearDown = false;
|
||||
|
||||
public $testSomething = false;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->setUp = true;
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->tearDown = true;
|
||||
}
|
||||
|
||||
public function testSomething(): void
|
||||
{
|
||||
$this->testSomething = true;
|
||||
}
|
||||
|
||||
protected function assertPreConditions(): void
|
||||
{
|
||||
$this->assertPreConditions = true;
|
||||
|
||||
throw new Exception;
|
||||
}
|
||||
|
||||
protected function assertPostConditions(): void
|
||||
{
|
||||
$this->assertPostConditions = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExceptionInSetUpTest extends TestCase
|
||||
{
|
||||
public $setUp = false;
|
||||
|
||||
public $assertPreConditions = false;
|
||||
|
||||
public $assertPostConditions = false;
|
||||
|
||||
public $tearDown = false;
|
||||
|
||||
public $testSomething = false;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->setUp = true;
|
||||
|
||||
throw new Exception;
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->tearDown = true;
|
||||
}
|
||||
|
||||
public function testSomething(): void
|
||||
{
|
||||
$this->testSomething = true;
|
||||
}
|
||||
|
||||
protected function assertPreConditions(): void
|
||||
{
|
||||
$this->assertPreConditions = true;
|
||||
}
|
||||
|
||||
protected function assertPostConditions(): void
|
||||
{
|
||||
$this->assertPostConditions = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExceptionInTearDownTest extends TestCase
|
||||
{
|
||||
public $setUp = false;
|
||||
|
||||
public $assertPreConditions = false;
|
||||
|
||||
public $assertPostConditions = false;
|
||||
|
||||
public $tearDown = false;
|
||||
|
||||
public $testSomething = false;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->setUp = true;
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->tearDown = true;
|
||||
|
||||
throw new Exception;
|
||||
}
|
||||
|
||||
public function testSomething(): void
|
||||
{
|
||||
$this->testSomething = true;
|
||||
}
|
||||
|
||||
protected function assertPreConditions(): void
|
||||
{
|
||||
$this->assertPreConditions = true;
|
||||
}
|
||||
|
||||
protected function assertPostConditions(): void
|
||||
{
|
||||
$this->assertPostConditions = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExceptionInTest extends TestCase
|
||||
{
|
||||
public $setUp = false;
|
||||
|
||||
public $assertPreConditions = false;
|
||||
|
||||
public $assertPostConditions = false;
|
||||
|
||||
public $tearDown = false;
|
||||
|
||||
public $testSomething = false;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->setUp = true;
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->tearDown = true;
|
||||
}
|
||||
|
||||
public function testSomething(): void
|
||||
{
|
||||
$this->testSomething = true;
|
||||
|
||||
throw new Exception;
|
||||
}
|
||||
|
||||
protected function assertPreConditions(): void
|
||||
{
|
||||
$this->assertPreConditions = true;
|
||||
}
|
||||
|
||||
protected function assertPostConditions(): void
|
||||
{
|
||||
$this->assertPostConditions = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use PHPUnit\Runner\BaseTestRunner;
|
||||
|
||||
class ExceptionInTestDetectedInTeardown extends TestCase
|
||||
{
|
||||
public $exceptionDetected = false;
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
if (BaseTestRunner::STATUS_ERROR == $this->getStatus()) {
|
||||
$this->exceptionDetected = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function testSomething(): void
|
||||
{
|
||||
throw new Exception;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace My\Space;
|
||||
|
||||
class ExceptionNamespaceTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* Exception message
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const ERROR_MESSAGE = 'Exception namespace message';
|
||||
|
||||
/**
|
||||
* Exception code
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const ERROR_CODE = 200;
|
||||
|
||||
/**
|
||||
* @expectedException Class
|
||||
* @expectedExceptionMessage My\Space\ExceptionNamespaceTest::ERROR_MESSAGE
|
||||
* @expectedExceptionCode My\Space\ExceptionNamespaceTest::ERROR_CODE
|
||||
*/
|
||||
public function testConstants(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Class
|
||||
* @expectedExceptionCode My\Space\ExceptionNamespaceTest::UNKNOWN_CODE_CONSTANT
|
||||
* @expectedExceptionMessage My\Space\ExceptionNamespaceTest::UNKNOWN_MESSAGE_CONSTANT
|
||||
*/
|
||||
public function testUnknownConstants(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExceptionStackTest extends TestCase
|
||||
{
|
||||
public function testPrintingChildException(): void
|
||||
{
|
||||
try {
|
||||
$this->assertEquals([1], [2], 'message');
|
||||
} catch (ExpectationFailedException $e) {
|
||||
$message = $e->getMessage() . $e->getComparisonFailure()->getDiff();
|
||||
|
||||
throw new PHPUnit\Framework\Exception("Child exception\n$message", 101, $e);
|
||||
}
|
||||
}
|
||||
|
||||
public function testNestedExceptions(): void
|
||||
{
|
||||
$exceptionThree = new Exception('Three');
|
||||
$exceptionTwo = new InvalidArgumentException('Two', 0, $exceptionThree);
|
||||
$exceptionOne = new Exception('One', 0, $exceptionTwo);
|
||||
|
||||
throw $exceptionOne;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExceptionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Exception message
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const ERROR_MESSAGE = 'Exception message';
|
||||
|
||||
/**
|
||||
* Exception message
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const ERROR_MESSAGE_REGEX = '#regex#';
|
||||
|
||||
/**
|
||||
* Exception code
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const ERROR_CODE = 500;
|
||||
|
||||
/**
|
||||
* @expectedException FooBarBaz
|
||||
*/
|
||||
public function testOne(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Foo_Bar_Baz
|
||||
*/
|
||||
public function testTwo(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Foo\Bar\Baz
|
||||
*/
|
||||
public function testThree(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException ほげ
|
||||
*/
|
||||
public function testFour(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Class Message 1234
|
||||
*/
|
||||
public function testFive(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Class
|
||||
* @expectedExceptionMessage Message
|
||||
* @expectedExceptionCode 1234
|
||||
*/
|
||||
public function testSix(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Class
|
||||
* @expectedExceptionMessage Message
|
||||
* @expectedExceptionCode ExceptionCode
|
||||
*/
|
||||
public function testSeven(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Class
|
||||
* @expectedExceptionMessage Message
|
||||
* @expectedExceptionCode 0
|
||||
*/
|
||||
public function testEight(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Class
|
||||
* @expectedExceptionMessage ExceptionTest::ERROR_MESSAGE
|
||||
* @expectedExceptionCode ExceptionTest::ERROR_CODE
|
||||
*/
|
||||
public function testNine(): void
|
||||
{
|
||||
}
|
||||
|
||||
/** @expectedException Class */
|
||||
public function testSingleLine(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Class
|
||||
* @expectedExceptionCode ExceptionTest::UNKNOWN_CODE_CONSTANT
|
||||
* @expectedExceptionMessage ExceptionTest::UNKNOWN_MESSAGE_CONSTANT
|
||||
*/
|
||||
public function testUnknownConstants(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Class
|
||||
* @expectedExceptionCode 1234
|
||||
* @expectedExceptionMessage Message
|
||||
* @expectedExceptionMessageRegExp #regex#
|
||||
*/
|
||||
public function testWithRegexMessage(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Class
|
||||
* @expectedExceptionCode 1234
|
||||
* @expectedExceptionMessage Message
|
||||
* @expectedExceptionMessageRegExp ExceptionTest::ERROR_MESSAGE_REGEX
|
||||
*/
|
||||
public function testWithRegexMessageFromClassConstant(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Class
|
||||
* @expectedExceptionCode 1234
|
||||
* @expectedExceptionMessage Message
|
||||
* @expectedExceptionMessageRegExp ExceptionTest::UNKNOWN_MESSAGE_REGEX_CONSTANT
|
||||
*/
|
||||
public function testWithUnknowRegexMessageFromClassConstant(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
interface ExceptionWithThrowable extends \Throwable
|
||||
{
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class Failure extends TestCase
|
||||
{
|
||||
protected function runTest(): void
|
||||
{
|
||||
$this->fail();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FailureTest extends TestCase
|
||||
{
|
||||
public function testAssertArrayEqualsArray(): void
|
||||
{
|
||||
$this->assertEquals([1], [2], 'message');
|
||||
}
|
||||
|
||||
public function testAssertIntegerEqualsInteger(): void
|
||||
{
|
||||
$this->assertEquals(1, 2, 'message');
|
||||
}
|
||||
|
||||
public function testAssertObjectEqualsObject(): void
|
||||
{
|
||||
$a = new stdClass;
|
||||
$a->foo = 'bar';
|
||||
|
||||
$b = new stdClass;
|
||||
$b->bar = 'foo';
|
||||
|
||||
$this->assertEquals($a, $b, 'message');
|
||||
}
|
||||
|
||||
public function testAssertNullEqualsString(): void
|
||||
{
|
||||
$this->assertEquals(null, 'bar', 'message');
|
||||
}
|
||||
|
||||
public function testAssertStringEqualsString(): void
|
||||
{
|
||||
$this->assertEquals('foo', 'bar', 'message');
|
||||
}
|
||||
|
||||
public function testAssertTextEqualsText(): void
|
||||
{
|
||||
$this->assertEquals("foo\nbar\n", "foo\nbaz\n", 'message');
|
||||
}
|
||||
|
||||
public function testAssertStringMatchesFormat(): void
|
||||
{
|
||||
$this->assertStringMatchesFormat('*%s*', '**', 'message');
|
||||
}
|
||||
|
||||
public function testAssertNumericEqualsNumeric(): void
|
||||
{
|
||||
$this->assertEquals(1, 2, 'message');
|
||||
}
|
||||
|
||||
public function testAssertTextSameText(): void
|
||||
{
|
||||
$this->assertSame('foo', 'bar', 'message');
|
||||
}
|
||||
|
||||
public function testAssertObjectSameObject(): void
|
||||
{
|
||||
$this->assertSame(new stdClass, new stdClass, 'message');
|
||||
}
|
||||
|
||||
public function testAssertObjectSameNull(): void
|
||||
{
|
||||
$this->assertSame(new stdClass, null, 'message');
|
||||
}
|
||||
|
||||
public function testAssertFloatSameFloat(): void
|
||||
{
|
||||
$this->assertSame(1.0, 1.5, 'message');
|
||||
}
|
||||
|
||||
// Note that due to the implementation of this assertion it counts as 2 asserts
|
||||
public function testAssertStringMatchesFormatFile(): void
|
||||
{
|
||||
$this->assertStringMatchesFormatFile(__DIR__ . '/expectedFileFormat.txt', '...BAR...');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\Constraint\Constraint;
|
||||
|
||||
final class FalsyConstraint extends Constraint
|
||||
{
|
||||
public function matches($other): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function toString(): string
|
||||
{
|
||||
return \sprintf(
|
||||
'is accepted by %s',
|
||||
self::class
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FatalTest extends TestCase
|
||||
{
|
||||
public function testFatalError(): void
|
||||
{
|
||||
if (\extension_loaded('xdebug')) {
|
||||
\xdebug_disable();
|
||||
}
|
||||
|
||||
eval('class FatalTest {}');
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class Foo
|
||||
{
|
||||
public function doSomething(Bar $bar)
|
||||
{
|
||||
return $bar->doSomethingElse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
function functionCallback()
|
||||
{
|
||||
$args = \func_get_args();
|
||||
|
||||
if ($args == ['foo', 'bar']) {
|
||||
return 'pass';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- WSDL description of the Google Web APIs.
|
||||
The Google Web APIs are in beta release. All interfaces are subject to
|
||||
change as we refine and extend our APIs. Please see the terms of use
|
||||
for more information. -->
|
||||
|
||||
<!-- Revision 2002-08-16 -->
|
||||
|
||||
<definitions name="GoogleSearch"
|
||||
targetNamespace="urn:GoogleSearch"
|
||||
xmlns:typens="urn:GoogleSearch"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
||||
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
||||
xmlns="http://schemas.xmlsoap.org/wsdl/">
|
||||
|
||||
<!-- Types for search - result elements, directory categories -->
|
||||
|
||||
<types>
|
||||
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="urn:GoogleSearch">
|
||||
|
||||
<xsd:complexType name="GoogleSearchResult">
|
||||
<xsd:all>
|
||||
<xsd:element name="documentFiltering" type="xsd:boolean"/>
|
||||
<xsd:element name="searchComments" type="xsd:string"/>
|
||||
<xsd:element name="estimatedTotalResultsCount" type="xsd:int"/>
|
||||
<xsd:element name="estimateIsExact" type="xsd:boolean"/>
|
||||
<xsd:element name="resultElements" type="typens:ResultElementArray"/>
|
||||
<xsd:element name="searchQuery" type="xsd:string"/>
|
||||
<xsd:element name="startIndex" type="xsd:int"/>
|
||||
<xsd:element name="endIndex" type="xsd:int"/>
|
||||
<xsd:element name="searchTips" type="xsd:string"/>
|
||||
<xsd:element name="directoryCategories" type="typens:DirectoryCategoryArray"/>
|
||||
<xsd:element name="searchTime" type="xsd:double"/>
|
||||
</xsd:all>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="ResultElement">
|
||||
<xsd:all>
|
||||
<xsd:element name="summary" type="xsd:string"/>
|
||||
<xsd:element name="URL" type="xsd:string"/>
|
||||
<xsd:element name="snippet" type="xsd:string"/>
|
||||
<xsd:element name="title" type="xsd:string"/>
|
||||
<xsd:element name="cachedSize" type="xsd:string"/>
|
||||
<xsd:element name="relatedInformationPresent" type="xsd:boolean"/>
|
||||
<xsd:element name="hostName" type="xsd:string"/>
|
||||
<xsd:element name="directoryCategory" type="typens:DirectoryCategory"/>
|
||||
<xsd:element name="directoryTitle" type="xsd:string"/>
|
||||
</xsd:all>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="ResultElementArray">
|
||||
<xsd:complexContent>
|
||||
<xsd:restriction base="soapenc:Array">
|
||||
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:ResultElement[]"/>
|
||||
</xsd:restriction>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="DirectoryCategoryArray">
|
||||
<xsd:complexContent>
|
||||
<xsd:restriction base="soapenc:Array">
|
||||
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:DirectoryCategory[]"/>
|
||||
</xsd:restriction>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="DirectoryCategory">
|
||||
<xsd:all>
|
||||
<xsd:element name="fullViewableName" type="xsd:string"/>
|
||||
<xsd:element name="specialEncoding" type="xsd:string"/>
|
||||
</xsd:all>
|
||||
</xsd:complexType>
|
||||
|
||||
</xsd:schema>
|
||||
</types>
|
||||
|
||||
<!-- Messages for Google Web APIs - cached page, search, spelling. -->
|
||||
|
||||
<message name="doGetCachedPage">
|
||||
<part name="key" type="xsd:string"/>
|
||||
<part name="url" type="xsd:string"/>
|
||||
</message>
|
||||
|
||||
<message name="doGetCachedPageResponse">
|
||||
<part name="return" type="xsd:base64Binary"/>
|
||||
</message>
|
||||
|
||||
<message name="doSpellingSuggestion">
|
||||
<part name="key" type="xsd:string"/>
|
||||
<part name="phrase" type="xsd:string"/>
|
||||
</message>
|
||||
|
||||
<message name="doSpellingSuggestionResponse">
|
||||
<part name="return" type="xsd:string"/>
|
||||
</message>
|
||||
|
||||
<!-- note, ie and oe are ignored by server; all traffic is UTF-8. -->
|
||||
|
||||
<message name="doGoogleSearch">
|
||||
<part name="key" type="xsd:string"/>
|
||||
<part name="q" type="xsd:string"/>
|
||||
<part name="start" type="xsd:int"/>
|
||||
<part name="maxResults" type="xsd:int"/>
|
||||
<part name="filter" type="xsd:boolean"/>
|
||||
<part name="restrict" type="xsd:string"/>
|
||||
<part name="safeSearch" type="xsd:boolean"/>
|
||||
<part name="lr" type="xsd:string"/>
|
||||
<part name="ie" type="xsd:string"/>
|
||||
<part name="oe" type="xsd:string"/>
|
||||
</message>
|
||||
|
||||
<message name="doGoogleSearchResponse">
|
||||
<part name="return" type="typens:GoogleSearchResult"/>
|
||||
</message>
|
||||
|
||||
<!-- Port for Google Web APIs, "GoogleSearch" -->
|
||||
|
||||
<portType name="GoogleSearchPort">
|
||||
|
||||
<operation name="doGetCachedPage">
|
||||
<input message="typens:doGetCachedPage"/>
|
||||
<output message="typens:doGetCachedPageResponse"/>
|
||||
</operation>
|
||||
|
||||
<operation name="doSpellingSuggestion">
|
||||
<input message="typens:doSpellingSuggestion"/>
|
||||
<output message="typens:doSpellingSuggestionResponse"/>
|
||||
</operation>
|
||||
|
||||
<operation name="doGoogleSearch">
|
||||
<input message="typens:doGoogleSearch"/>
|
||||
<output message="typens:doGoogleSearchResponse"/>
|
||||
</operation>
|
||||
|
||||
</portType>
|
||||
|
||||
|
||||
<!-- Binding for Google Web APIs - RPC, SOAP over HTTP -->
|
||||
|
||||
<binding name="GoogleSearchBinding" type="typens:GoogleSearchPort">
|
||||
<soap:binding style="rpc"
|
||||
transport="http://schemas.xmlsoap.org/soap/http"/>
|
||||
|
||||
<operation name="doGetCachedPage">
|
||||
<soap:operation soapAction="urn:GoogleSearchAction"/>
|
||||
<input>
|
||||
<soap:body use="encoded"
|
||||
namespace="urn:GoogleSearch"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="encoded"
|
||||
namespace="urn:GoogleSearch"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</output>
|
||||
</operation>
|
||||
|
||||
<operation name="doSpellingSuggestion">
|
||||
<soap:operation soapAction="urn:GoogleSearchAction"/>
|
||||
<input>
|
||||
<soap:body use="encoded"
|
||||
namespace="urn:GoogleSearch"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="encoded"
|
||||
namespace="urn:GoogleSearch"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</output>
|
||||
</operation>
|
||||
|
||||
<operation name="doGoogleSearch">
|
||||
<soap:operation soapAction="urn:GoogleSearchAction"/>
|
||||
<input>
|
||||
<soap:body use="encoded"
|
||||
namespace="urn:GoogleSearch"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="encoded"
|
||||
namespace="urn:GoogleSearch"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</output>
|
||||
</operation>
|
||||
</binding>
|
||||
|
||||
<!-- Endpoint for Google Web APIs -->
|
||||
<service name="GoogleSearchService">
|
||||
<port name="GoogleSearchPort" binding="typens:GoogleSearchBinding">
|
||||
<soap:address location="http://api.google.com/search/beta2"/>
|
||||
</port>
|
||||
</service>
|
||||
|
||||
</definitions>
|
||||
@@ -0,0 +1,198 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- WSDL description of the Google Web APIs.
|
||||
The Google Web APIs are in beta release. All interfaces are subject to
|
||||
change as we refine and extend our APIs. Please see the terms of use
|
||||
for more information. -->
|
||||
|
||||
<!-- Revision 2002-08-16 -->
|
||||
|
||||
<definitions name="GoogleSearch"
|
||||
targetNamespace="urn:GoogleSearch"
|
||||
xmlns:typens="urn:GoogleSearch"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
||||
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
||||
xmlns="http://schemas.xmlsoap.org/wsdl/">
|
||||
|
||||
<!-- Types for search - result elements, directory categories -->
|
||||
|
||||
<types>
|
||||
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="urn:GoogleSearch">
|
||||
|
||||
<xsd:complexType name="GoogleSearchResult">
|
||||
<xsd:all>
|
||||
<xsd:element name="documentFiltering" type="xsd:boolean"/>
|
||||
<xsd:element name="searchComments" type="xsd:string"/>
|
||||
<xsd:element name="estimatedTotalResultsCount" type="xsd:int"/>
|
||||
<xsd:element name="estimateIsExact" type="xsd:boolean"/>
|
||||
<xsd:element name="resultElements" type="typens:ResultElementArray"/>
|
||||
<xsd:element name="searchQuery" type="xsd:string"/>
|
||||
<xsd:element name="startIndex" type="xsd:int"/>
|
||||
<xsd:element name="endIndex" type="xsd:int"/>
|
||||
<xsd:element name="searchTips" type="xsd:string"/>
|
||||
<xsd:element name="directoryCategories" type="typens:DirectoryCategoryArray"/>
|
||||
<xsd:element name="searchTime" type="xsd:double"/>
|
||||
</xsd:all>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="ResultElement">
|
||||
<xsd:all>
|
||||
<xsd:element name="summary" type="xsd:string"/>
|
||||
<xsd:element name="URL" type="xsd:string"/>
|
||||
<xsd:element name="snippet" type="xsd:string"/>
|
||||
<xsd:element name="title" type="xsd:string"/>
|
||||
<xsd:element name="cachedSize" type="xsd:string"/>
|
||||
<xsd:element name="relatedInformationPresent" type="xsd:boolean"/>
|
||||
<xsd:element name="hostName" type="xsd:string"/>
|
||||
<xsd:element name="directoryCategory" type="typens:DirectoryCategory"/>
|
||||
<xsd:element name="directoryTitle" type="xsd:string"/>
|
||||
</xsd:all>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="ResultElementArray">
|
||||
<xsd:complexContent>
|
||||
<xsd:restriction base="soapenc:Array">
|
||||
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:ResultElement[]"/>
|
||||
</xsd:restriction>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="DirectoryCategoryArray">
|
||||
<xsd:complexContent>
|
||||
<xsd:restriction base="soapenc:Array">
|
||||
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:DirectoryCategory[]"/>
|
||||
</xsd:restriction>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="DirectoryCategory">
|
||||
<xsd:all>
|
||||
<xsd:element name="fullViewableName" type="xsd:string"/>
|
||||
<xsd:element name="specialEncoding" type="xsd:string"/>
|
||||
</xsd:all>
|
||||
</xsd:complexType>
|
||||
|
||||
</xsd:schema>
|
||||
</types>
|
||||
|
||||
<!-- Messages for Google Web APIs - cached page, search, spelling. -->
|
||||
|
||||
<message name="doGetCachedPage">
|
||||
<part name="key" type="xsd:string"/>
|
||||
<part name="url" type="xsd:string"/>
|
||||
</message>
|
||||
|
||||
<message name="doGetCachedPageResponse">
|
||||
<part name="return" type="xsd:base64Binary"/>
|
||||
</message>
|
||||
|
||||
<message name="doSpellingSuggestion">
|
||||
<part name="key" type="xsd:string"/>
|
||||
<part name="phrase" type="xsd:string"/>
|
||||
</message>
|
||||
|
||||
<message name="doSpellingSuggestionResponse">
|
||||
<part name="return" type="xsd:string"/>
|
||||
</message>
|
||||
|
||||
<!-- note, ie and oe are ignored by server; all traffic is UTF-8. -->
|
||||
|
||||
<message name="doGoogleSearch">
|
||||
<part name="key" type="xsd:string"/>
|
||||
<part name="q" type="xsd:string"/>
|
||||
<part name="start" type="xsd:int"/>
|
||||
<part name="maxResults" type="xsd:int"/>
|
||||
<part name="filter" type="xsd:boolean"/>
|
||||
<part name="restrict" type="xsd:string"/>
|
||||
<part name="safeSearch" type="xsd:boolean"/>
|
||||
<part name="lr" type="xsd:string"/>
|
||||
<part name="ie" type="xsd:string"/>
|
||||
<part name="oe" type="xsd:string"/>
|
||||
</message>
|
||||
|
||||
<message name="doGoogleSearchResponse">
|
||||
<part name="return" type="typens:GoogleSearchResult"/>
|
||||
</message>
|
||||
|
||||
<!-- Port for Google Web APIs, "GoogleSearch" -->
|
||||
|
||||
<portType name="GoogleSearchPort">
|
||||
|
||||
<operation name="doGetCachedPage">
|
||||
<input message="typens:doGetCachedPage"/>
|
||||
<output message="typens:doGetCachedPageResponse"/>
|
||||
</operation>
|
||||
|
||||
<operation name="doSpellingSuggestion">
|
||||
<input message="typens:doSpellingSuggestion"/>
|
||||
<output message="typens:doSpellingSuggestionResponse"/>
|
||||
</operation>
|
||||
|
||||
<operation name="doGoogleSearch">
|
||||
<input message="typens:doGoogleSearch"/>
|
||||
<output message="typens:doGoogleSearchResponse"/>
|
||||
</operation>
|
||||
|
||||
</portType>
|
||||
|
||||
|
||||
<!-- Binding for Google Web APIs - RPC, SOAP over HTTP -->
|
||||
|
||||
<binding name="GoogleSearchBinding" type="typens:GoogleSearchPort">
|
||||
<soap:binding style="rpc"
|
||||
transport="http://schemas.xmlsoap.org/soap/http"/>
|
||||
|
||||
<operation name="doGetCachedPage">
|
||||
<soap:operation soapAction="urn:GoogleSearchAction"/>
|
||||
<input>
|
||||
<soap:body use="encoded"
|
||||
namespace="urn:GoogleSearch"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="encoded"
|
||||
namespace="urn:GoogleSearch"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</output>
|
||||
</operation>
|
||||
|
||||
<operation name="doSpellingSuggestion">
|
||||
<soap:operation soapAction="urn:GoogleSearchAction"/>
|
||||
<input>
|
||||
<soap:body use="encoded"
|
||||
namespace="urn:GoogleSearch"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="encoded"
|
||||
namespace="urn:GoogleSearch"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</output>
|
||||
</operation>
|
||||
|
||||
<operation name="doGoogleSearch">
|
||||
<soap:operation soapAction="urn:GoogleSearchAction"/>
|
||||
<input>
|
||||
<soap:body use="encoded"
|
||||
namespace="urn:GoogleSearch"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="encoded"
|
||||
namespace="urn:GoogleSearch"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</output>
|
||||
</operation>
|
||||
</binding>
|
||||
|
||||
<!-- Endpoint for Google Web APIs -->
|
||||
<service name="GoogleSearchService">
|
||||
<port name="GoogleSearchPort" binding="typens:GoogleSearchBinding">
|
||||
<soap:address location="http://api.google.com/search/beta2"/>
|
||||
</port>
|
||||
</service>
|
||||
|
||||
</definitions>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class IgnoreCodeCoverageClass
|
||||
{
|
||||
public function returnTrue()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function returnFalse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user