Add pear modules, mail and net_smtp via composer (#93)

Add pear modules, mail and net_smtp via composer, remove php 5.6 build due to phpunit 6
This commit is contained in:
Thilina Hasantha
2018-01-08 23:13:43 +01:00
committed by GitHub
parent 359e3f8382
commit e7792e7d79
2349 changed files with 117270 additions and 83170 deletions

View File

@@ -1,6 +1,6 @@
<?php
/*
* This file is part of the PHPUnit_MockObject package.
* This file is part of the phpunit-mock-objects package.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
@@ -8,7 +8,11 @@
* file that was distributed with this source code.
*/
class Framework_MockObjectTest extends PHPUnit_Framework_TestCase
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\ExpectationFailedException;
class MockObjectTest extends TestCase
{
public function testMockedMethodIsNeverCalled()
{
@@ -167,9 +171,9 @@ class Framework_MockObjectTest extends PHPUnit_Framework_TestCase
$mock->expects($this->any())
->method('doSomething')
->will($this->throwException(new Exception));
->will($this->throwException(new \Exception()));
$this->expectException(Exception::class);
$this->expectException(\Exception::class);
$mock->doSomething();
}
@@ -181,9 +185,9 @@ class Framework_MockObjectTest extends PHPUnit_Framework_TestCase
$mock->expects($this->any())
->method('doSomething')
->willThrowException(new Exception);
->willThrowException(new \Exception());
$this->expectException(Exception::class);
$this->expectException(\Exception::class);
$mock->doSomething();
}
@@ -429,9 +433,6 @@ class Framework_MockObjectTest extends PHPUnit_Framework_TestCase
$this->assertNotEquals(get_class($mock4), get_class($mock5));
}
/**
* @covers PHPUnit_Framework_MockObject_Generator::getMock
*/
public function testGetMockWithFixedClassNameCanProduceTheSameMockTwice()
{
$mock = $this->getMockBuilder(stdClass::class)->setMockClassName('FixedName')->getMock();
@@ -658,10 +659,10 @@ class Framework_MockObjectTest extends PHPUnit_Framework_TestCase
try {
$mock->__phpunit_verify();
$this->fail('Expected exception');
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
} catch (ExpectationFailedException $e) {
$this->assertSame(
"Expectation failed for method name is equal to <string:right> when invoked 1 time(s).\n"
. "Method was expected to be called 1 times, actually called 0 times.\n",
'Expectation failed for method name is equal to "right" when invoked 1 time(s).' . PHP_EOL .
'Method was expected to be called 1 times, actually called 0 times.' . PHP_EOL,
$e->getMessage()
);
}
@@ -683,10 +684,10 @@ class Framework_MockObjectTest extends PHPUnit_Framework_TestCase
try {
$mock->__phpunit_verify();
$this->fail('Expected exception');
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
} catch (ExpectationFailedException $e) {
$this->assertSame(
"Expectation failed for method name is equal to <string:right> when invoked 1 time(s).\n"
. "Method was expected to be called 1 times, actually called 0 times.\n",
'Expectation failed for method name is equal to "right" when invoked 1 time(s).' . PHP_EOL .
'Method was expected to be called 1 times, actually called 0 times.' . PHP_EOL,
$e->getMessage()
);
}
@@ -706,31 +707,33 @@ class Framework_MockObjectTest extends PHPUnit_Framework_TestCase
try {
$mock->right(['second']);
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
} catch (ExpectationFailedException $e) {
$this->assertSame(
"Expectation failed for method name is equal to <string:right> when invoked 1 time(s)\n"
. "Parameter 0 for invocation SomeClass::right(Array (...)) does not match expected value.\n"
. 'Failed asserting that two arrays are equal.',
'Expectation failed for method name is equal to "right" when invoked 1 time(s)' . PHP_EOL .
'Parameter 0 for invocation SomeClass::right(Array (...)) does not match expected value.' . PHP_EOL .
'Failed asserting that two arrays are equal.',
$e->getMessage()
);
}
try {
$mock->__phpunit_verify();
$this->fail('Expected exception');
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
// CHECKOUT THIS MORE CAREFULLY
// $this->fail('Expected exception');
} catch (ExpectationFailedException $e) {
$this->assertSame(
"Expectation failed for method name is equal to <string:right> when invoked 1 time(s).\n"
. "Parameter 0 for invocation SomeClass::right(Array (...)) does not match expected value.\n"
. "Failed asserting that two arrays are equal.\n"
. "--- Expected\n"
. "+++ Actual\n"
. "@@ @@\n"
. " Array (\n"
. "- 0 => 'first'\n"
. "- 1 => 'second'\n"
. "+ 0 => 'second'\n"
. " )\n",
'Expectation failed for method name is equal to "right" when invoked 1 time(s).' . PHP_EOL .
'Parameter 0 for invocation SomeClass::right(Array (...)) does not match expected value.' . PHP_EOL .
'Failed asserting that two arrays are equal.' . PHP_EOL .
'--- Expected' . PHP_EOL .
'+++ Actual' . PHP_EOL .
'@@ @@' . PHP_EOL .
' Array (' . PHP_EOL .
'- 0 => \'first\'' . PHP_EOL .
'- 1 => \'second\'' . PHP_EOL .
'+ 0 => \'second\'' . PHP_EOL,
$e->getMessage()
);
}
@@ -751,7 +754,7 @@ class Framework_MockObjectTest extends PHPUnit_Framework_TestCase
try {
$mock->right();
$this->fail('Expected exception');
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
} catch (ExpectationFailedException $e) {
$this->assertSame(
'SomeClass::right() was not expected to be called.',
$e->getMessage()
@@ -774,7 +777,7 @@ class Framework_MockObjectTest extends PHPUnit_Framework_TestCase
try {
$mock->right();
$this->fail('Expected exception');
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
} catch (ExpectationFailedException $e) {
$this->assertSame(
'SomeClass::right() was not expected to be called.',
$e->getMessage()
@@ -797,10 +800,10 @@ class Framework_MockObjectTest extends PHPUnit_Framework_TestCase
try {
$mock->right();
$this->fail('Expected exception');
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
} catch (ExpectationFailedException $e) {
$this->assertSame(
"Expectation failed for method name is equal to <string:right> when invoked 1 time(s)\n" .
"Parameter count for invocation SomeClass::right() is too low.\n" .
'Expectation failed for method name is equal to "right" when invoked 1 time(s)' . PHP_EOL .
'Parameter count for invocation SomeClass::right() is too low.' . PHP_EOL .
'To allow 0 or more parameters with any value, omit ->with() or use ->withAnyParameters() instead.',
$e->getMessage()
);
@@ -950,13 +953,12 @@ class Framework_MockObjectTest extends PHPUnit_Framework_TestCase
);
}
/**
* @expectedException PHPUnit_Framework_MockObject_BadMethodCallException
*/
public function testInvokingStubbedStaticMethodRaisesException()
{
$mock = $this->getMockBuilder(ClassWithStaticMethod::class)->getMock();
$this->expectException(\PHPUnit\Framework\MockObject\BadMethodCallException::class);
$mock->staticMethod();
}
@@ -1034,4 +1036,40 @@ class Framework_MockObjectTest extends PHPUnit_Framework_TestCase
$mock->bar('call_' . $i);
}
}
public function testReturnTypesAreMockedCorrectly()
{
/** @var ClassWithAllPossibleReturnTypes|MockObject $stub */
$stub = $this->createMock(ClassWithAllPossibleReturnTypes::class);
$this->assertNull($stub->methodWithNoReturnTypeDeclaration());
$this->assertSame('', $stub->methodWithStringReturnTypeDeclaration());
$this->assertSame(0.0, $stub->methodWithFloatReturnTypeDeclaration());
$this->assertSame(0, $stub->methodWithIntReturnTypeDeclaration());
$this->assertFalse($stub->methodWithBoolReturnTypeDeclaration());
$this->assertSame([], $stub->methodWithArrayReturnTypeDeclaration());
$this->assertInstanceOf(MockObject::class, $stub->methodWithClassReturnTypeDeclaration());
}
/**
* @requires PHP 7.1
*/
public function testVoidReturnTypeIsMockedCorrectly()
{
/** @var ClassWithAllPossibleReturnTypes|MockObject $stub */
$stub = $this->createMock(ClassWithAllPossibleReturnTypes::class);
$this->assertNull($stub->methodWithVoidReturnTypeDeclaration());
}
/**
* @requires PHP 7.2
*/
public function testObjectReturnTypeIsMockedCorrectly()
{
/** @var ClassWithAllPossibleReturnTypes|MockObject $stub */
$stub = $this->createMock(ClassWithAllPossibleReturnTypes::class);
$this->assertInstanceOf(stdClass::class, $stub->methodWithObjectReturnTypeDeclaration());
}
}