CounterpartFinderTest.php 2.37 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
<?php

namespace LQDN\Tests\Functional\Finder;

use LQDN\Tests\Functional\FunctionalTest;

class CounterpartFinderTest extends FunctionalTest
{
    public function testFindByUserId()
    {
        $counterparts = $this->container['counterpart_finder']->findByUserId(2);
12
        $this->assertCount(3, $counterparts);
13 14 15 16 17 18 19 20 21

        $firstCounterpart = reset($counterparts);

        // Check the first counterpart
        $expectedCounterpart = [
            'id' => '2',
            'user_id' => '2',
            'datec' => '2016-06-22 12:34:00',
            'quoi' => 'piplome',
22
            'taille' => '2',
23
            'status' => '2',
24
            'adresse_id' => null,
Okhin's avatar
Okhin committed
25
            'pdf_id' => '1',
26
            'pdf_nom' => 'Main',
Okhin's avatar
Okhin committed
27
            'pdf_url' => 'pdf',
28
            'commentaire' => '',
29
            'parent' => '4',
30 31 32
        ];
        $this->assertEquals($expectedCounterpart, $firstCounterpart);
    }
33 34 35 36 37 38 39 40 41 42 43 44 45 46

    public function testFindByQuoi()
    {
        $counterparts = $this->container['counterpart_finder']->findByQuoi('piplome');
        $this->assertCount(1, $counterparts);
        $firstCounterpart = reset($counterparts);

        // Check the first counterpart
        $expectedCounterpart = [
            'id' => '2',
            'user_id' => '2',
            'datec' => '2016-06-22 12:34:00',
            'quoi' => 'piplome',
            'taille' => '2',
47
            'status' => '2',
48 49 50 51 52
            'adresse_id' => null,
            'pdf_id' => '1',
            'pdf_nom' => 'Main',
            'pdf_url' => 'pdf',
            'commentaire' => '',
53
            'parent' => '4',
54 55 56 57 58 59 60 61
        ];
        $this->assertEquals($expectedCounterpart, $firstCounterpart);

    }

    public function testFindById()
    {
        $counterparts = $this->container['counterpart_finder']->findByStatus(1);
62
        $this->assertCount(1, $counterparts);
63 64 65 66 67 68 69 70 71 72 73 74 75 76

        $firstCounterpart = reset($counterparts);
        $expectedCounterpart = [
            'id' => '1',
            'datec' => '2016-06-22 12:34:00',
            'user_id' => '1',
            'quoi' => 'pishirt', // [piplome|pibag|pishirt|hoodie]
            'taille' => '8',
            'status' => '1',
            'adresse_id' => '1',
            'pdf_id' => '',
            'pdf_nom' => '',
            'pdf_url' => '',
            'commentaire' => '',
77
            'parent' => '1',
78 79 80
        ];
        $this->assertEquals($expectedCounterpart, $firstCounterpart);
    }
81
}