Issues (4)

tests/ContainerTest.php (2 issues)

Labels
1
<?php
2
3
/**
4
 * @author    : Jagepard <[email protected]">
5
 * @license   https://mit-license.org/ MIT
6
 *
7
 *  phpunit src/tests/ContainerTest --coverage-html src/tests/coverage-html
8
 */
9
10
namespace Primate\Container\Tests;
11
12
use Primate\Container\Container;
13
use PHPUnit\Framework\TestCase as PHPUnit_Framework_TestCase;
14
use Primate\Container\ContainerInterface;
15
16
class ContainerTest extends PHPUnit_Framework_TestCase
17
{
18
    private ContainerInterface $primate;
19
20
    protected function setUp(): void
21
    {
22
        require "./vendor/autoload.php";
23
24
        $this->primate = new Container([ContainerTest::class => $this]);
25
    }
26
27
    public function testInstances()
28
    {
29
        $this->assertInstanceOf(Container::class, $this->primate);
30
    }
31
32
    public function testGetInvalidArgumentException(): void
33
    {
34
        $this->expectException(\InvalidArgumentException::class);
35
        $this->primate->get("wrongKey");
36
    }
37
38
    public function testSet(): void
39
    {
40
        $this->assertInstanceOf(ContainerTest::class, $this->primate->get(ContainerTest::class));
0 ignored issues
show
Are you sure the usage of $this->primate->get(Prim...s\ContainerTest::class) targeting Primate\Container\ContainerInterface::get() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
41
    }
42
43
    public function testGetArrayHasKey(): void
44
    {
45
        $this->assertArrayHasKey(ContainerTest::class, $this->primate->get());
0 ignored issues
show
Are you sure the usage of $this->primate->get() targeting Primate\Container\ContainerInterface::get() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
46
    }
47
48
49
    public function testHas(): void
50
    {
51
        $this->assertTrue($this->primate->has(ContainerTest::class));
52
    }
53
}
54