|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace PhpSchool\PhpWorkshopTest\ExerciseRunner\Factory; |
| 4 | + |
| 5 | +use PhpSchool\PhpWorkshop\CommandDefinition; |
| 6 | +use PhpSchool\PhpWorkshop\Exercise\CustomVerifyingExercise; |
| 7 | +use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; |
| 8 | +use PhpSchool\PhpWorkshop\Exercise\ExerciseType; |
| 9 | +use PhpSchool\PhpWorkshop\ExerciseRunner\CustomVerifyingRunner; |
| 10 | +use PhpSchool\PhpWorkshop\ExerciseRunner\Factory\CustomVerifyingRunnerFactory; |
| 11 | +use PhpSchool\PhpWorkshopTest\Asset\CustomVerifyingExerciseImpl; |
| 12 | +use PHPUnit_Framework_TestCase; |
| 13 | + |
| 14 | +/** |
| 15 | + * @author Aydin Hassan <aydin@hotmail.co.uk> |
| 16 | + */ |
| 17 | +class CustomRunnerFactoryTest extends PHPUnit_Framework_TestCase |
| 18 | +{ |
| 19 | + /** |
| 20 | + * @var CustomVerifyingRunnerFactory |
| 21 | + */ |
| 22 | + private $factory; |
| 23 | + |
| 24 | + public function setUp() |
| 25 | + { |
| 26 | + $this->factory = new CustomVerifyingRunnerFactory; |
| 27 | + } |
| 28 | + |
| 29 | + public function testSupports() |
| 30 | + { |
| 31 | + $exercise1 = $this->prophesize(ExerciseInterface::class); |
| 32 | + $exercise2 = $this->prophesize(ExerciseInterface::class); |
| 33 | + $exercise3 = $this->prophesize(ExerciseInterface::class); |
| 34 | + |
| 35 | + $exercise1->getType()->willReturn(ExerciseType::CLI()); |
| 36 | + $exercise2->getType()->willReturn(ExerciseType::CGI()); |
| 37 | + $exercise3->getType()->willReturn(ExerciseType::CUSTOM()); |
| 38 | + |
| 39 | + $this->assertFalse($this->factory->supports($exercise1->reveal())); |
| 40 | + $this->assertFalse($this->factory->supports($exercise2->reveal())); |
| 41 | + $this->assertTrue($this->factory->supports($exercise3->reveal())); |
| 42 | + } |
| 43 | + |
| 44 | + public function testConfigureInputAddsNoArgument() |
| 45 | + { |
| 46 | + $command = new CommandDefinition('my-command', [], 'var_dump'); |
| 47 | + |
| 48 | + $this->factory->configureInput($command); |
| 49 | + $this->assertCount(0, $command->getRequiredArgs()); |
| 50 | + } |
| 51 | + |
| 52 | + public function testCreateReturnsRunner() |
| 53 | + { |
| 54 | + $exercise = new CustomVerifyingExerciseImpl; |
| 55 | + $this->assertInstanceOf(CustomVerifyingRunner::class, $this->factory->create($exercise)); |
| 56 | + } |
| 57 | +} |
0 commit comments