SingleValueDataSetTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testBase() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Tests\DataSet;
6
7
use PHPUnit\Framework\TestCase;
8
use Yiisoft\Validator\DataSet\SingleValueDataSet;
9
10
final class SingleValueDataSetTest extends TestCase
11
{
12
    public function testBase(): void
13
    {
14
        $data = new SingleValueDataSet(['test' => 'hello']);
15
16
        $this->assertNull($data->getData());
0 ignored issues
show
Bug introduced by
Are you sure the usage of $data->getData() targeting Yiisoft\Validator\DataSe...ValueDataSet::getData() 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...
17
        $this->assertSame(['test' => 'hello'], $data->getSource());
18
        $this->assertFalse($data->hasAttribute('test'));
19
        $this->assertNull($data->getAttributeValue('test'));
20
    }
21
}
22