1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace PhpSchool\Php7WayTest\Exercise; |
5
|
|
|
|
6
|
|
|
use PhpSchool\Php7Way\Exercise\TypeYourArguments; |
7
|
|
|
use PhpSchool\PhpWorkshop\Exercise\ExerciseType; |
8
|
|
|
use PhpSchool\PhpWorkshop\Check\FunctionRequirementsCheck; |
9
|
|
|
use PhpSchool\PhpWorkshop\Solution\SolutionInterface; |
10
|
|
|
use PhpSchool\PhpWorkshop\ExerciseDispatcher; |
11
|
|
|
use PHPUnit_Framework_TestCase; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class TypeYourArgumentsTest |
15
|
|
|
* @package PhpSchool\Php7WayTest\Exercise |
16
|
|
|
*/ |
17
|
|
View Code Duplication |
class TypeYourArgumentsTest extends PHPUnit_Framework_TestCase |
|
|
|
|
18
|
|
|
{ |
19
|
|
|
public function testTypeYourArgumentsExercise() |
20
|
|
|
{ |
21
|
|
|
$e = new TypeYourArguments(); |
22
|
|
|
$this->assertEquals('Type your arguments!', $e->getName()); |
23
|
|
|
$this->assertEquals('Use scalar types with arguments', $e->getDescription()); |
24
|
|
|
$this->assertEquals(ExerciseType::CLI, $e->getType()); |
25
|
|
|
|
26
|
|
|
$this->assertEquals([], $e->getArgs()); |
27
|
|
|
|
28
|
|
|
$this->assertInstanceOf(SolutionInterface::class, $e->getSolution()); |
29
|
|
|
$this->assertFileExists(realpath($e->getProblem())); |
30
|
|
|
$this->assertNull($e->tearDown()); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testFunctionRequirements() |
34
|
|
|
{ |
35
|
|
|
$e = new TypeYourArguments(); |
36
|
|
|
$this->assertEquals(['noStrictFunction', 'strictFunction'], $e->getRequiredFunctions()); |
37
|
|
|
$this->assertEquals([], $e->getBannedFunctions()); |
38
|
|
|
} |
39
|
|
|
public function testConfigure() |
40
|
|
|
{ |
41
|
|
|
$dispatcher = $this->getMockBuilder(ExerciseDispatcher::class) |
42
|
|
|
->disableOriginalConstructor() |
43
|
|
|
->getMock(); |
44
|
|
|
$dispatcher |
45
|
|
|
->expects($this->once()) |
46
|
|
|
->method('requireCheck') |
47
|
|
|
->with(FunctionRequirementsCheck::class); |
48
|
|
|
$e = new TypeYourArguments(); |
49
|
|
|
$e->configure($dispatcher); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.