Skip to content

Commit d351125

Browse files
authored
Merge pull request #119 from php-school/phpunit-deprecations
Phpunit deprecations
2 parents 9d087e0 + b93ec42 commit d351125

File tree

55 files changed

+313
-392
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+313
-392
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
"require-dev": {
3636
"composer/composer": "^1.0-alpha",
37-
"phpunit/phpunit": "^5.1",
37+
"phpunit/phpunit": "^5.4",
3838
"squizlabs/php_codesniffer": "^2.4"
3939
},
4040
"autoload" : {

composer.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/Check/CheckRepositoryTest.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class CheckRepositoryTest extends PHPUnit_Framework_TestCase
1616
{
1717
public function testRegisterViaConstructor()
1818
{
19-
$check = $this->getMock(CheckInterface::class);
19+
$check = $this->createMock(CheckInterface::class);
2020
$repository = new CheckRepository([$check]);
2121
$this->assertEquals([$check], $repository->getAll());
2222
}
@@ -26,17 +26,17 @@ public function testRegisterCheck()
2626
$repository = new CheckRepository;
2727
$this->assertEquals([], $repository->getAll());
2828

29-
$check = $this->getMock(CheckInterface::class);
29+
$check = $this->createMock(CheckInterface::class);
3030
$repository->registerCheck($check);
3131
$this->assertEquals([$check], $repository->getAll());
3232
}
3333

3434
public function testHas()
3535
{
3636
$repository = new CheckRepository;
37-
$repository->registerCheck($this->getMock(CheckInterface::class));
37+
$repository->registerCheck($this->createMock(CheckInterface::class));
3838

39-
$check = $this->getMock(CheckInterface::class);
39+
$check = $this->createMock(CheckInterface::class);
4040
$repository->registerCheck($check);
4141

4242
$this->assertTrue($repository->has(get_class($check)));
@@ -46,22 +46,20 @@ public function testHas()
4646
public function testGetByClassThrowsExceptionIfNotExist()
4747
{
4848
$repository = new CheckRepository;
49-
$repository->registerCheck($this->getMock(CheckInterface::class));
49+
$repository->registerCheck($this->createMock(CheckInterface::class));
5050

51-
$this->setExpectedException(
52-
InvalidArgumentException::class,
53-
'Check: "SomeClassWhichDoesNotExist" does not exist'
54-
);
51+
$this->expectException(InvalidArgumentException::class);
52+
$this->expectExceptionMessage('Check: "SomeClassWhichDoesNotExist" does not exist');
5553

5654
$repository->getByClass('SomeClassWhichDoesNotExist');
5755
}
5856

5957
public function testGetByClass()
6058
{
6159
$repository = new CheckRepository;
62-
$repository->registerCheck($this->getMock(CheckInterface::class));
60+
$repository->registerCheck($this->createMock(CheckInterface::class));
6361

64-
$check = $this->getMock(CheckInterface::class);
62+
$check = $this->createMock(CheckInterface::class);
6563
$repository->registerCheck($check);
6664

6765
$this->assertSame($check, $repository->getByClass(get_class($check)));

test/Check/CodeParseCheckTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testUnParseableCodeReturnsFailure()
4848
{
4949
file_put_contents($this->file, '<?php $lol');
5050

51-
$result = $this->check->check($this->getMock(ExerciseInterface::class), $this->file);
51+
$result = $this->check->check($this->createMock(ExerciseInterface::class), $this->file);
5252
$this->assertInstanceOf(Failure::class, $result);
5353

5454
$this->assertEquals('Code Parse Check', $result->getCheckName());
@@ -62,7 +62,7 @@ public function testParseableCodeReturnsSuccess()
6262
{
6363
file_put_contents($this->file, '<?php $lol = "lol";');
6464

65-
$result = $this->check->check($this->getMock(ExerciseInterface::class), $this->file);
65+
$result = $this->check->check($this->createMock(ExerciseInterface::class), $this->file);
6666
$this->assertInstanceOf(Success::class, $result);
6767

6868
$this->assertEquals('Code Parse Check', $result->getCheckName());

test/Check/ComposerCheckTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public function setUp()
4545

4646
public function testExceptionIsThrownIfNotValidExercise()
4747
{
48-
$exercise = $this->getMock(ExerciseInterface::class);
49-
$this->setExpectedException(InvalidArgumentException::class);
48+
$exercise = $this->createMock(ExerciseInterface::class);
49+
$this->expectException(InvalidArgumentException::class);
5050

5151
$this->check->check($exercise, '');
5252
}
@@ -77,7 +77,7 @@ public function testCheckReturnsFailureIfNoComposerLockFile()
7777
*/
7878
public function testCheckReturnsFailureIfDependencyNotRequired($dependency, $solutionFile)
7979
{
80-
$exercise = $this->getMock(ComposerExercise::class);
80+
$exercise = $this->createMock(ComposerExercise::class);
8181
$exercise->expects($this->once())
8282
->method('getRequiredPackages')
8383
->will($this->returnValue([$dependency]));

test/Check/DatabaseCheckTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class DatabaseCheckTest extends PHPUnit_Framework_TestCase
4545
public function setUp()
4646
{
4747
$this->check = new DatabaseCheck;
48-
$this->exercise = $this->getMock(DatabaseExerciseInterface::class);
48+
$this->exercise = $this->createMock(DatabaseExerciseInterface::class);
4949
$this->dbDir = sprintf(
5050
'%s/PhpSchool_PhpWorkshop_Check_DatabaseCheck',
5151
str_replace('\\', '/', realpath(sys_get_temp_dir()))
@@ -194,7 +194,7 @@ public function testRunExercise()
194194
$dispatcher->run(
195195
$this->exercise,
196196
__DIR__ . '/../res/database/user-solution-alter-db.php',
197-
$this->getMock(OutputInterface::class)
197+
$this->createMock(OutputInterface::class)
198198
);
199199
}
200200

test/Check/FileExistsCheckTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function setUp()
3737
$this->testDir = sprintf('%s/%s', sys_get_temp_dir(), $this->getName());
3838
mkdir($this->testDir, 0777, true);
3939
$this->check = new FileExistsCheck;
40-
$this->exercise = $this->getMock(ExerciseInterface::class);
40+
$this->exercise = $this->createMock(ExerciseInterface::class);
4141
$this->assertEquals('File Exists Check', $this->check->getName());
4242
$this->assertEquals(ExerciseInterface::class, $this->check->getExerciseInterface());
4343
$this->assertEquals(SimpleCheckInterface::CHECK_BEFORE, $this->check->getPosition());

test/Check/FunctionRequirementsCheckTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public function setUp()
5454

5555
public function testExceptionIsThrownIfNotValidExercise()
5656
{
57-
$exercise = $this->getMock(ExerciseInterface::class);
58-
$this->setExpectedException(InvalidArgumentException::class);
57+
$exercise = $this->createMock(ExerciseInterface::class);
58+
$this->expectException(InvalidArgumentException::class);
5959

6060
$this->check->check($exercise, '');
6161
}
@@ -84,7 +84,7 @@ public function testFailureIsReturnedIfBannedFunctionsAreUsed()
8484

8585
public function testFailureIsReturnedIfNotAllRequiredFunctionsHaveBeenUsed()
8686
{
87-
$exercise = $this->getMock(FunctionRequirementsExercise::class);
87+
$exercise = $this->createMock(FunctionRequirementsExercise::class);
8888
$exercise
8989
->expects($this->once())
9090
->method('getBannedFunctions')
@@ -107,7 +107,7 @@ public function testFailureIsReturnedIfNotAllRequiredFunctionsHaveBeenUsed()
107107

108108
public function testSuccess()
109109
{
110-
$exercise = $this->getMock(FunctionRequirementsExercise::class);
110+
$exercise = $this->createMock(FunctionRequirementsExercise::class);
111111
$exercise
112112
->expects($this->once())
113113
->method('getBannedFunctions')

test/Check/PhpLintCheckTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class PhpLintCheckTest extends PHPUnit_Framework_TestCase
3131
public function setUp()
3232
{
3333
$this->check = new PhpLintCheck;
34-
$this->exercise = $this->getMock(ExerciseInterface::class);
34+
$this->exercise = $this->createMock(ExerciseInterface::class);
3535
$this->assertEquals('PHP Code Check', $this->check->getName());
3636
$this->assertEquals(ExerciseInterface::class, $this->check->getExerciseInterface());
3737
$this->assertEquals(SimpleCheckInterface::CHECK_BEFORE, $this->check->getPosition());

test/CodeInsertionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class CodeInsertionTest extends PHPUnit_Framework_TestCase
1515
{
1616
public function testInvalidType()
1717
{
18-
$this->setExpectedException(InvalidArgumentException::class);
18+
$this->expectException(InvalidArgumentException::class);
1919
new CodeInsertion('notatype', '');
2020
}
2121

2222
public function testInvalidCode()
2323
{
24-
$this->setExpectedException(InvalidArgumentException::class);
24+
$this->expectException(InvalidArgumentException::class);
2525
new CodeInsertion(CodeInsertion::TYPE_BEFORE, new \stdClass);
2626
}
2727

0 commit comments

Comments
 (0)