ChainResolverTests::testResolve()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 22
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Cubiche\Core\Cqrs\Tests\Units\Middlewares\Handler\Resolver\NameOfQuery;
13
14
use Cubiche\Core\Bus\Exception\NotFoundException;
15
use Cubiche\Core\Cqrs\Middlewares\Handler\Resolver\NameOfQuery\ChainResolver;
16
use Cubiche\Core\Cqrs\Middlewares\Handler\Resolver\NameOfQuery\FromClassNameResolver;
17
use Cubiche\Core\Cqrs\Middlewares\Handler\Resolver\NameOfQuery\FromQueryNamedResolver;
18
use Cubiche\Core\Cqrs\Tests\Fixtures\Query\NearbyVenuesQuery;
19
use Cubiche\Core\Cqrs\Tests\Fixtures\Query\PublishedPostsQuery;
20
use Cubiche\Core\Cqrs\Tests\Units\TestCase;
21
22
/**
23
 * ChainResolver class.
24
 *
25
 * Generated by TestGenerator on 2016-04-07 at 15:40:41.
26
 */
27
class ChainResolverTests extends TestCase
28
{
29
    /**
30
     * Test Resolve method.
31
     */
32
    public function testResolve()
33
    {
34
        $this
35
            ->given($resolver1 = new FromQueryNamedResolver())
36
            ->and($resolver2 = new FromClassNameResolver())
37
            ->and($resolver = new ChainResolver([$resolver1, $resolver2]))
38
            ->when($result = $resolver->resolve(new PublishedPostsQuery(new \DateTime())))
39
            ->then()
40
                ->string($result)
41
                    ->isEqualTo(PublishedPostsQuery::class)
42
            ->and()
43
            ->when(
44
                $result = $resolver->resolve(
45
                    new NearbyVenuesQuery($this->faker->latitude(), $this->faker->longitude())
46
                )
47
            )
48
            ->then()
49
                ->string($result)
50
                    ->isEqualTo('aroundVenues')
51
        ;
52
53
        $this
54
            ->given($resolver = new ChainResolver([]))
55
            ->then()
56
                ->exception(function () use ($resolver) {
57
                    $resolver->resolve(new NearbyVenuesQuery($this->faker->latitude(), $this->faker->longitude()));
58
                })
59
                ->isInstanceOf(NotFoundException::class)
60
        ;
61
    }
62
}
63