Skip to content

Commit

Permalink
add Util tests
Browse files Browse the repository at this point in the history
  • Loading branch information
howyi committed Aug 1, 2017
1 parent e84b75d commit 76a2cde
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/Conv/Util/FieldOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,4 @@ public function getNextAfterField()
{
return $this->nextAfterField;
}

}
17 changes: 17 additions & 0 deletions tests/Conv/Util/FieldOrderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Conv\Util;

class FieldOrderTest extends \PHPUnit\Framework\TestCase
{
public function testConstruct()
{
$field = 'user_name';
$previousAfterField = 'user_id';
$nextAfterField = 'age';
$fieldOrder = new FieldOrder($field, $previousAfterField, $nextAfterField);
$this->assertSame($field, $fieldOrder->getField());
$this->assertSame($previousAfterField, $fieldOrder->getPreviousAfterField());
$this->assertSame($nextAfterField, $fieldOrder->getNextAfterField());
}
}
41 changes: 41 additions & 0 deletions tests/Conv/Util/OperatorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Conv\Util;

use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ChoiceQuestion;

class OperatorTest extends \PHPUnit\Framework\TestCase
{
private $prophet;

protected function setup()
{
$this->prophet = new \Prophecy\Prophet;
}

protected function tearDown()
{
$this->prophet->checkPredictions();
}

public function testConstruct()
{
$helper = $this->prophet->prophesize(QuestionHelper::class);
$input = $this->prophet->prophesize(InputInterface::class);
$output = $this->prophet->prophesize(OutputInterface::class);
$operator = new Operator($helper->reveal(), $input->reveal(), $output->reveal());

$answer = 'answer';
$helper->ask($input, $output, \Prophecy\Argument::type(ChoiceQuestion::class))
->willReturn($answer)
->shouldBeCalledTimes(1);
$this->assertSame($answer, $operator->choiceQuestion('question', ['answer']));

$message = 'message';
$output->writeln($message)->shouldBeCalledTimes(1);
$operator->output($message);
}
}

0 comments on commit 76a2cde

Please sign in to comment.