Skip to content

Commit

Permalink
Remove useless code
Browse files Browse the repository at this point in the history
  • Loading branch information
AydinHassan committed May 17, 2024
1 parent 6142580 commit 74bef1f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 85 deletions.
10 changes: 0 additions & 10 deletions test/Asset/CgiExerciseInterface.php

This file was deleted.

8 changes: 7 additions & 1 deletion test/Asset/CliExerciseImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class CliExerciseImpl implements ExerciseInterface, CliExercise
{
private string $name;
private string $problemFile = 'problem-file.md';
private SolutionInterface $solution;
private CliScenario $scenario;

Expand Down Expand Up @@ -43,7 +44,12 @@ public function getSolution(): SolutionInterface

public function getProblem(): string
{
// TODO: Implement getProblem() method.
return $this->problemFile;
}

public function setProblem(string $problemFile): void
{
$this->problemFile = $problemFile;
}

public function tearDown(): void
Expand Down
10 changes: 0 additions & 10 deletions test/Asset/CliExerciseInterface.php

This file was deleted.

11 changes: 0 additions & 11 deletions test/Asset/DatabaseExerciseInterface.php

This file was deleted.

19 changes: 4 additions & 15 deletions test/Command/PrintCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
namespace PhpSchool\PhpWorkshopTest\Command;

use PhpSchool\PhpWorkshop\Command\PrintCommand;
use PhpSchool\PhpWorkshop\Exercise\ExerciseType;
use PhpSchool\PhpWorkshop\UserState\UserState;
use PhpSchool\PhpWorkshopTest\Asset\CliExerciseInterface;
use PhpSchool\PhpWorkshopTest\Asset\CliExerciseImpl;
use PHPUnit\Framework\TestCase;
use PhpSchool\PhpWorkshop\ExerciseRepository;
use PhpSchool\PhpWorkshop\MarkdownRenderer;
Expand All @@ -18,23 +17,13 @@ public function testExerciseIsPrintedIfAssigned(): void
$file = tempnam(sys_get_temp_dir(), 'pws');
file_put_contents($file, '### Exercise 1');

$exercise = $this->createMock(CliExerciseInterface::class);
$exercise
->method('getProblem')
->willReturn($file);

$exercise
->method('getType')
->willReturn(ExerciseType::CLI());

$exercise
->method('getName')
->willReturn('some-exercise');
$exercise = new CliExerciseImpl();
$exercise->setProblem($file);

$repo = new ExerciseRepository([$exercise]);

$state = new UserState();
$state->setCurrentExercise('some-exercise');
$state->setCurrentExercise('my-exercise');

$output = $this->createMock(OutputInterface::class);
$renderer = $this->createMock(MarkdownRenderer::class);
Expand Down
49 changes: 11 additions & 38 deletions test/UserState/LocalJsonSerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,18 @@
use PhpSchool\PhpWorkshop\UserState\UserState;
use PhpSchool\PhpWorkshop\Utils\Path;
use PhpSchool\PhpWorkshop\Utils\System;
use PhpSchool\PhpWorkshopTest\Asset\CliExerciseInterface;
use PhpSchool\PhpWorkshopTest\Asset\CliExerciseImpl;
use PhpSchool\PhpWorkshopTest\BaseTest;
use Yoast\PHPUnitPolyfills\Polyfills\AssertionRenames;

class LocalJsonSerializerTest extends BaseTest
{
use AssertionRenames;

/**
* @var string
*/
private $tmpDir;

/**
* @var string
*/
private $tmpFile;

/**
* @var string
*/
private $workshopName = 'My Workshop';

/**
* @var ExerciseRepository
*/
private $exerciseRepository;
private string $tmpDir;
private string $tmpFile;
private string $workshopName = 'My Workshop';
private ExerciseRepository $exerciseRepository;

public function setUp(): void
{
Expand Down Expand Up @@ -201,12 +186,8 @@ public function deserializerProvider(): array

public function testOldDataWillBeMigratedWhenInCorrectWorkshop(): void
{
$exercise1 = $this->createMock(CliExerciseInterface::class);
$exercise2 = $this->createMock(CliExerciseInterface::class);
$exercise1->method('getType')->willReturn(ExerciseType::CLI());
$exercise2->method('getType')->willReturn(ExerciseType::CLI());
$exercise1->method('getName')->willReturn('Exercise 1');
$exercise2->method('getName')->willReturn('Exercise 2');
$exercise1 = new CliExerciseImpl('Exercise 1');
$exercise2 = new CliExerciseImpl('Exercise 2');

$oldData = [
'current_exercise' => 'Exercise 3',
Expand Down Expand Up @@ -246,12 +227,8 @@ public function testOldDataWillBeMigratedWhenInCorrectWorkshop(): void

public function testOldDataWillNotBeMigratedWhenNotInCorrectWorkshop(): void
{
$exercise1 = $this->createMock(CliExerciseInterface::class);
$exercise2 = $this->createMock(CliExerciseInterface::class);
$exercise1->method('getType')->willReturn(ExerciseType::CLI());
$exercise2->method('getType')->willReturn(ExerciseType::CLI());
$exercise1->method('getName')->willReturn('Exercise 1');
$exercise2->method('getName')->willReturn('Exercise 2');
$exercise1 = new CliExerciseImpl('Exercise 1');
$exercise2 = new CliExerciseImpl('Exercise 2');

$exercises = [
$exercise1,
Expand Down Expand Up @@ -279,12 +256,8 @@ public function testOldDataWillNotBeMigratedWhenNotInCorrectWorkshop(): void

public function testOldDataWillNotBeMigratedWhenNotInCorrectWorkshopWithOtherWorkshop(): void
{
$exercise1 = $this->createMock(CliExerciseInterface::class);
$exercise2 = $this->createMock(CliExerciseInterface::class);
$exercise1->method('getType')->willReturn(ExerciseType::CLI());
$exercise2->method('getType')->willReturn(ExerciseType::CLI());
$exercise1->method('getName')->willReturn('Exercise 1');
$exercise2->method('getName')->willReturn('Exercise 2');
$exercise1 = new CliExerciseImpl('Exercise 1');
$exercise2 = new CliExerciseImpl('Exercise 2');

$oldData = [
'current_exercise' => 'Exercise 3',
Expand Down

0 comments on commit 74bef1f

Please sign in to comment.