Skip to content

Commit

Permalink
RoundDateTimeSpec must extends ObjectBehavior (#222)
Browse files Browse the repository at this point in the history
* RoundDateTimeSpec must extends ObjectBehavior

* fix error in RoundDateTimeSpec

* fix CS error
  • Loading branch information
peter-gribanov committed Oct 28, 2019
1 parent 5ea3e75 commit fa746f0
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions tests/Result/RoundDateTimeSpec.php
Expand Up @@ -6,11 +6,12 @@
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\Query\Parameter;
use Happyr\DoctrineSpecification\Result\RoundDateTime;
use PhpSpec\ObjectBehavior;

/**
* @mixin RoundDateTime
*/
class RoundDateTimeSpec
class RoundDateTimeSpec extends ObjectBehavior
{
private $roundSeconds = 3600;

Expand All @@ -31,16 +32,14 @@ public function it_round_date_time_in_query_parameters_for_given_time(
) {
$name = 'now';
$type = 'datetime';
$date = new \DateTime('15:55:34');

$scalarParam->getValue()->willReturn('foo');

$datetimeParam->getValue()->willReturn($date);
$datetimeParam->getName()->willReturn($name);
$datetimeParam->getType()->willReturn($type);

$query->getParameters()->willReturn(new ArrayCollection([$scalarParam, $datetimeParam]));
$query->setParameter($name, new \DateTime('15:00:00'), $type)->shouldBeCalled();
$actual = new \DateTime('15:55:34');
$expected = new \DateTimeImmutable('15:00:00');

$query->getParameters()->willReturn(new ArrayCollection([
new Parameter('status', 'active'), // scalar param
new Parameter($name, $actual, $type),
]));
$query->setParameter($name, $expected, $type)->shouldBeCalled();

$this->modify($query);
}
Expand Down

0 comments on commit fa746f0

Please sign in to comment.