Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove useless code #293

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading