Passed
Pull Request — master (#77)
by Marco
08:43
created

ColumnarTest::assertEqualsDump()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Firesphere\SolrSearch\Tests;
4
5
use Firesphere\SolrSearch\Helpers\Columnar;
6
use SilverStripe\CMS\Model\SiteTree;
7
use SilverStripe\Control\HTTPRequestBuilder;
8
use SilverStripe\Core\Injector\Injector;
9
use SilverStripe\Dev\Debug;
10
use SilverStripe\Dev\SapphireTest;
11
use SilverStripe\ORM\DatabaseAdmin;
12
use SilverStripe\ORM\DB;
13
14
class ColumnarTest extends SapphireTest
15
{
16
    protected static $fixture_file = 'tests/fixtures/Columnar.yml';
17
18
    public function assertEqualsDump()
19
    {
20
        Debug::dump(func_get_args());
21
    }
22
23
    public static function setUpBeforeClass()
24
    {
25
        parent::setUpBeforeClass();
26
        // This is a hack on my local dev to make fixtures populate temporary database
27
        $conn = DB::get_conn();
28
        $dbName = self::tempDB()->build();
29
        $conn->selectDatabase($dbName);
30
        $dbAdmin = new DatabaseAdmin();
31
        $dbAdmin->setRequest(HTTPRequestBuilder::createFromEnvironment());
32
        $dbAdmin->doBuild(true, true, true);
33
    }
34
35
    public function test_DataObjectEmptyColumnIsToMap()
36
    {
37
        $objectOne = $this->objFromFixture(TestObject::class, 'objectOne');
38
        $this->assertEquals($objectOne->toMap(), Columnar::identify($objectOne, ''));
0 ignored issues
show
Bug introduced by
Are you sure the usage of Firesphere\SolrSearch\He...dentify($objectOne, '') targeting Firesphere\SolrSearch\Helpers\Columnar::identify() 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...
39
    }
40
41
    public function test_DataListEmptyColumnIsToNestedArray()
42
    {
43
        $objectOne = $this->objFromFixture(TestObject::class, 'objectOne');
44
        $dataList = $objectOne->TestPages();
45
        $this->assertEquals($dataList->toNestedArray(), Columnar::identify($dataList, ''));
0 ignored issues
show
Bug introduced by
Are you sure the usage of Firesphere\SolrSearch\He...identify($dataList, '') targeting Firesphere\SolrSearch\Helpers\Columnar::identify() 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
    public function test_DataObjectGetMethod()
49
    {
50
        $pageOne = $this->objFromFixture(TestPage::class, 'pageOne');
51
        $this->assertEquals($pageOne->getSalutation(), Columnar::identify($pageOne, 'Salutation'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of Firesphere\SolrSearch\He...$pageOne, 'Salutation') targeting Firesphere\SolrSearch\Helpers\Columnar::identify() 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...
52
    }
53
54
    public function test_DataObjectAttributes()
55
    {
56
        $mockDate = '2019-07-04 22:01:00';
57
        $pageOne = $this->objFromFixture(TestPage::class, 'pageOne');
58
        $pageOne->Created = $mockDate;
59
        $pageOne->write();
60
        $this->assertEquals($pageOne->Title, Columnar::identify($pageOne, 'Title'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of Firesphere\SolrSearch\He...tify($pageOne, 'Title') targeting Firesphere\SolrSearch\Helpers\Columnar::identify() 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...
61
        $this->assertEquals($mockDate, $pageOne->Created);
62
        $this->assertEquals($mockDate, Columnar::identify($pageOne, 'Created'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of Firesphere\SolrSearch\He...fy($pageOne, 'Created') targeting Firesphere\SolrSearch\Helpers\Columnar::identify() 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...
63
        $this->assertEquals('Jul 4, 2019, 10:01 PM', Columnar::identify($pageOne, 'Created.Nice'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of Firesphere\SolrSearch\He...ageOne, 'Created.Nice') targeting Firesphere\SolrSearch\Helpers\Columnar::identify() 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...
64
        $this->assertEquals('2019-07-04T22:01:00+00:00', Columnar::identify($pageOne, 'Created.Rfc3339'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of Firesphere\SolrSearch\He...One, 'Created.Rfc3339') targeting Firesphere\SolrSearch\Helpers\Columnar::identify() 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...
65
    }
66
67
    public function test_DataTraversal()
68
    {
69
        $mockDate = '2019-07-04 22:01:00';
70
        $objectOne = $this->objFromFixture(TestObject::class, 'objectOne');
71
        $pageOne = $this->objFromFixture(TestPage::class, 'pageOne');
72
        $relationOne = $this->objFromFixture(TestRelationObject::class, 'relationOne');
73
        $relationOne->Created = $mockDate;
74
        $relationOne->write();
75
        $this->assertEquals($objectOne->toMap(), Columnar::identify($pageOne, 'TestObject'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of Firesphere\SolrSearch\He...$pageOne, 'TestObject') targeting Firesphere\SolrSearch\Helpers\Columnar::identify() 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...
76
        $this->assertEquals($objectOne->Title, Columnar::identify($pageOne, 'TestObject.Title'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of Firesphere\SolrSearch\He...ne, 'TestObject.Title') targeting Firesphere\SolrSearch\Helpers\Columnar::identify() 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...
77
        $this->assertEquals(0, Columnar::identify($pageOne, 'TestObject.ShowInSearch'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of Firesphere\SolrSearch\He...stObject.ShowInSearch') targeting Firesphere\SolrSearch\Helpers\Columnar::identify() 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...
78
        $this->assertEquals('No', Columnar::identify($pageOne, 'TestObject.ShowInSearch.Nice'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of Firesphere\SolrSearch\He...ect.ShowInSearch.Nice') targeting Firesphere\SolrSearch\Helpers\Columnar::identify() 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...
79
        $this->assertEquals($objectOne->TestRelation()->toNestedArray(), Columnar::identify($pageOne, 'TestObject.TestRelation'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of Firesphere\SolrSearch\He...stObject.TestRelation') targeting Firesphere\SolrSearch\Helpers\Columnar::identify() 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...
80
        $this->assertEquals($objectOne->TestRelation()->First()->toMap(), Columnar::identify($pageOne, 'TestObject.TestRelation.First'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of Firesphere\SolrSearch\He...ct.TestRelation.First') targeting Firesphere\SolrSearch\Helpers\Columnar::identify() 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...
81
        $this->assertEquals($relationOne->Title, Columnar::identify($pageOne, 'TestObject.TestRelation.First.Title'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of Firesphere\SolrSearch\He...tRelation.First.Title') targeting Firesphere\SolrSearch\Helpers\Columnar::identify() 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...
82
        $this->assertEquals($mockDate, Columnar::identify($pageOne, 'TestObject.TestRelation.First.Created'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of Firesphere\SolrSearch\He...elation.First.Created') targeting Firesphere\SolrSearch\Helpers\Columnar::identify() 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...
83
        $this->assertEquals($mockDate, $relationOne->Created);
84
        $this->assertEquals('Jul 4, 2019, 10:01 PM', Columnar::identify($pageOne, 'TestObject.TestRelation.First.Created.Nice'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of Firesphere\SolrSearch\He...on.First.Created.Nice') targeting Firesphere\SolrSearch\Helpers\Columnar::identify() 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...
85
        $this->assertEquals('2019-07-04T22:01:00+00:00', Columnar::identify($pageOne, 'TestObject.TestRelation.First.Created.Rfc3339'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of Firesphere\SolrSearch\He...First.Created.Rfc3339') targeting Firesphere\SolrSearch\Helpers\Columnar::identify() 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...
86
    }
87
}