| @@ 17-52 (lines=36) @@ | ||
| 14 | * Class ArrayWeFilterTest |
|
| 15 | * @package PhpSchool\LearnYouPhpTest\Exercise |
|
| 16 | */ |
|
| 17 | class ArrayWeFilterTest extends PHPUnit_Framework_TestCase |
|
| 18 | { |
|
| 19 | public function testArrayWeMapExercise() |
|
| 20 | { |
|
| 21 | $e = new ArrayWeFilter(); |
|
| 22 | $this->assertEquals('Array we filter!', $e->getName()); |
|
| 23 | $this->assertEquals('Exercice with array filter', $e->getDescription()); |
|
| 24 | $this->assertEquals(ExerciseType::CLI, $e->getType()); |
|
| 25 | ||
| 26 | $this->assertEquals([1, 2, 3, 4, 5], $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 ArrayWeFilter(); |
|
| 36 | $this->assertEquals(['array_filter'], $e->getRequiredFunctions()); |
|
| 37 | $this->assertEquals([], $e->getBannedFunctions()); |
|
| 38 | } |
|
| 39 | ||
| 40 | public function testConfigure() |
|
| 41 | { |
|
| 42 | $dispatcher = $this->getMockBuilder(ExerciseDispatcher::class) |
|
| 43 | ->disableOriginalConstructor() |
|
| 44 | ->getMock(); |
|
| 45 | $dispatcher |
|
| 46 | ->expects($this->once()) |
|
| 47 | ->method('requireCheck') |
|
| 48 | ->with(FunctionRequirementsCheck::class); |
|
| 49 | $e = new ArrayWeFilter(); |
|
| 50 | $e->configure($dispatcher); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| @@ 17-52 (lines=36) @@ | ||
| 14 | * Class ArrayWeMapTest |
|
| 15 | * @package PhpSchool\LearnYouPhpTest\Exercise |
|
| 16 | */ |
|
| 17 | class ArrayWeMapTest extends PHPUnit_Framework_TestCase |
|
| 18 | { |
|
| 19 | public function testArrayWeMapExercise() |
|
| 20 | { |
|
| 21 | $e = new ArrayWeMap(); |
|
| 22 | $this->assertEquals('Array we map!', $e->getName()); |
|
| 23 | $this->assertEquals('Exercice with array map', $e->getDescription()); |
|
| 24 | $this->assertEquals(ExerciseType::CLI, $e->getType()); |
|
| 25 | ||
| 26 | $this->assertEquals(['Sarra', 'Helen', 'Anas'], $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 ArrayWeMap(); |
|
| 36 | $this->assertEquals(['array_map'], $e->getRequiredFunctions()); |
|
| 37 | $this->assertEquals([], $e->getBannedFunctions()); |
|
| 38 | } |
|
| 39 | ||
| 40 | public function testConfigure() |
|
| 41 | { |
|
| 42 | $dispatcher = $this->getMockBuilder(ExerciseDispatcher::class) |
|
| 43 | ->disableOriginalConstructor() |
|
| 44 | ->getMock(); |
|
| 45 | $dispatcher |
|
| 46 | ->expects($this->once()) |
|
| 47 | ->method('requireCheck') |
|
| 48 | ->with(FunctionRequirementsCheck::class); |
|
| 49 | $e = new ArrayWeMap(); |
|
| 50 | $e->configure($dispatcher); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| @@ 17-52 (lines=36) @@ | ||
| 14 | * Class ArrayWeReduceTest |
|
| 15 | * @package PhpSchool\LearnYouPhpTest\Exercise |
|
| 16 | */ |
|
| 17 | class ArrayWeReduceTest extends PHPUnit_Framework_TestCase |
|
| 18 | { |
|
| 19 | public function testArrayWeMapExercise() |
|
| 20 | { |
|
| 21 | $e = new ArrayWeReduce(); |
|
| 22 | $this->assertEquals('Array we reduce!', $e->getName()); |
|
| 23 | $this->assertEquals('Exercice with array reduce', $e->getDescription()); |
|
| 24 | $this->assertEquals(ExerciseType::CLI, $e->getType()); |
|
| 25 | ||
| 26 | $this->assertEquals([1, 2, 3], $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 ArrayWeReduce(); |
|
| 36 | $this->assertEquals(['array_reduce'], $e->getRequiredFunctions()); |
|
| 37 | $this->assertEquals([], $e->getBannedFunctions()); |
|
| 38 | } |
|
| 39 | ||
| 40 | public function testConfigure() |
|
| 41 | { |
|
| 42 | $dispatcher = $this->getMockBuilder(ExerciseDispatcher::class) |
|
| 43 | ->disableOriginalConstructor() |
|
| 44 | ->getMock(); |
|
| 45 | $dispatcher |
|
| 46 | ->expects($this->once()) |
|
| 47 | ->method('requireCheck') |
|
| 48 | ->with(FunctionRequirementsCheck::class); |
|
| 49 | $e = new ArrayWeReduce(); |
|
| 50 | $e->configure($dispatcher); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| @@ 17-52 (lines=36) @@ | ||
| 14 | * Class PeaceWalkTest |
|
| 15 | * @package PhpSchool\LearnYouPhpTest\Exercise |
|
| 16 | */ |
|
| 17 | class PeaceWalkTest extends PHPUnit_Framework_TestCase |
|
| 18 | { |
|
| 19 | public function testPeaceWalkExercise() |
|
| 20 | { |
|
| 21 | $e = new PeaceWalk(); |
|
| 22 | $this->assertEquals('Peace walk', $e->getName()); |
|
| 23 | $this->assertEquals('Exercice with array_walk', $e->getDescription()); |
|
| 24 | $this->assertEquals(ExerciseType::CLI, $e->getType()); |
|
| 25 | ||
| 26 | $this->assertEquals(['Sarra', 'Helen', 'Anas'], $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 PeaceWalk(); |
|
| 36 | $this->assertEquals(['array_walk'], $e->getRequiredFunctions()); |
|
| 37 | $this->assertEquals([], $e->getBannedFunctions()); |
|
| 38 | } |
|
| 39 | ||
| 40 | public function testConfigure() |
|
| 41 | { |
|
| 42 | $dispatcher = $this->getMockBuilder(ExerciseDispatcher::class) |
|
| 43 | ->disableOriginalConstructor() |
|
| 44 | ->getMock(); |
|
| 45 | $dispatcher |
|
| 46 | ->expects($this->once()) |
|
| 47 | ->method('requireCheck') |
|
| 48 | ->with(FunctionRequirementsCheck::class); |
|
| 49 | $e = new PeaceWalk(); |
|
| 50 | $e->configure($dispatcher); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||