CounterpartHandlerTest.php 1.23 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
<?php

namespace LQDN\Tests\Functional\Handler;

use LQDN\Command\CounterpartCreateCommand;
use LQDN\Command\CounterpartDeleteCommand;
use LQDN\Command\CounterpartChangeStateCommand;
use LQDN\Handler\CounterpartHandler;
use LQDN\Tests\Functional\FunctionalTest;

class CounterpartHandlerTest extends FunctionalTest
{
    public function testCounterpartDelete()
    {
        $this->assertTrue($this->counterpartExists(1));

        $this->container['command_handler']->handle(new CounterpartDeleteCommand(1));
    }

    public function testCounterpartCreate()
    {
        $this->assertFalse($this->counterpartExists(3));

okhin's avatar
okhin committed
24
        $this->container['command_handler']->handle(new CounterpartCreateCommand(1, 1, 'pishirt', 4, 1, date("Y-m-d H:i:s"), ''));
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
    }

    public function testCounterpartChangeState()
    {
        $this->assertTrue($this->counterpartExists(1));

        $this->container['command_handler']->handle(new CounterpartChangeStateCommand(1, 2));
    }

    /**
     * Check if a counterpart exists in BDD
     *
     * @param int $id
     *
     * @return bool
     */
    private function counterpartExists($id)
    {
        return (bool) $this->container['db']->fetchColumn("SELECT 1 FROM contreparties WHERE id = $id");
    }
}