Issues (39)

tests/src/Commands/CommandsCollectionTest.php (1 issue)

1
<?php
2
3
namespace Nip\Dispatcher\Tests\Commands;
4
5
use Nip\Dispatcher\Commands\Command;
6
use Nip\Dispatcher\Commands\CommandsCollection;
7
use Nip\Dispatcher\Tests\AbstractTest;
8
9
/**
10
 * Class CommandTest
11
 * @package Nip\Dispatcher\Tests\Commands
12
 */
13
class CommandsCollectionTest extends AbstractTest
14
{
15
    public function testOverflow()
16
    {
17
        $collection = new CommandsCollection();
18
        $collection->setMaxHops(3);
19
20
        self::assertEquals(3, $collection->getMaxHops());
21
        self::assertEquals(0, $collection->getHops());
22
        self::assertFalse($collection->overflow());
23
24
        $command = new Command();
25
        $collection[] = $command;
26
        $collection[] = $command;
27
        self::assertEquals(2, $collection->getHops());
28
        self::assertFalse($collection->overflow());
29
30
        $collection[] = $command;
31
        self::assertEquals(3, $collection->getHops());
32
        self::assertFalse($collection->overflow());
33
34
        self::expectException(\Exception::class);
0 ignored issues
show
Bug Best Practice introduced by
The method PHPUnit\Framework\TestCase::expectException() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
        self::/** @scrutinizer ignore-call */ 
35
              expectException(\Exception::class);
Loading history...
35
        $collection[] = $command;
36
        self::assertTrue($collection->overflow());
37
    }
38
}
39