Passed
Push — master ( 1ba0c5...41126d )
by Jean Paul
01:47
created

StackOverflowJobTest::testSetGetJobId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 13
rs 10
1
<?php declare( strict_types = 1 );
2
3
namespace Coco\SourceWatcher\Tests\Vendors\StackOverflow;
4
5
use Coco\SourceWatcher\Vendors\StackOverflow\StackOverflowJob;
6
use PHPUnit\Framework\TestCase;
7
8
/**
9
 * Class StackOverflowJobTest
10
 * @package Coco\SourceWatcher\Tests\Vendors\StackOverflow
11
 */
12
class StackOverflowJobTest extends TestCase
13
{
14
    /**
15
     *
16
     */
17
    public function testSetGetJobId () : void
18
    {
19
        $stackOverflowJob = new StackOverflowJob();
20
21
        $givenJobId = "123456";
22
        $expectedJobId = "123456";
23
24
        $stackOverflowJob->setJobId( $givenJobId );
25
        $this->assertNotNull( $stackOverflowJob->getJobId() );
26
        $this->assertEquals( $expectedJobId, $stackOverflowJob->getJobId() );
27
28
        $stackOverflowJob->setJobId( null );
29
        $this->assertNull( $stackOverflowJob->getJobId() );
0 ignored issues
show
Bug introduced by
Are you sure the usage of $stackOverflowJob->getJobId() targeting Coco\SourceWatcher\Vendo...OverflowJob::getJobId() 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...
30
    }
31
32
    /**
33
     *
34
     */
35
    public function testSetGetResultId () : void
36
    {
37
        $stackOverflowJob = new StackOverflowJob();
38
39
        $givenResultId = "123456";
40
        $expectedResultId = "123456";
41
42
        $stackOverflowJob->setResultId( $givenResultId );
43
        $this->assertNotNull( $stackOverflowJob->getResultId() );
44
        $this->assertEquals( $expectedResultId, $stackOverflowJob->getResultId() );
45
46
        $stackOverflowJob->setResultId( null );
47
        $this->assertNull( $stackOverflowJob->getResultId() );
0 ignored issues
show
Bug introduced by
Are you sure the usage of $stackOverflowJob->getResultId() targeting Coco\SourceWatcher\Vendo...rflowJob::getResultId() 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...
48
    }
49
50
    /**
51
     *
52
     */
53
    public function testSetGetPreviewURL () : void
54
    {
55
        $stackOverflowJob = new StackOverflowJob();
56
57
        $givenPreviewUrl = "https://stackoverflow.com/jobs/123456/some-developer-role";
58
        $expectedPreviewUrl = "https://stackoverflow.com/jobs/123456/some-developer-role";
59
60
        $stackOverflowJob->setPreviewUrl( $givenPreviewUrl );
61
        $this->assertNotNull( $stackOverflowJob->getPreviewUrl() );
62
        $this->assertEquals( $expectedPreviewUrl, $stackOverflowJob->getPreviewUrl() );
63
64
        $stackOverflowJob->setPreviewUrl( null );
65
        $this->assertNull( $stackOverflowJob->getPreviewUrl() );
0 ignored issues
show
Bug introduced by
Are you sure the usage of $stackOverflowJob->getPreviewUrl() targeting Coco\SourceWatcher\Vendo...lowJob::getPreviewUrl() 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...
66
    }
67
68
    /**
69
     *
70
     */
71
    public function testSetGetLogo () : void
72
    {
73
        $stackOverflowJob = new StackOverflowJob();
74
75
        $givenLogo = "https://some-website.com/assets/some-logo.svg";
76
        $expectedLogo = "https://some-website.com/assets/some-logo.svg";
77
78
        $stackOverflowJob->setLogo( $givenLogo );
79
        $this->assertNotNull( $stackOverflowJob->getLogo() );
80
        $this->assertEquals( $expectedLogo, $stackOverflowJob->getLogo() );
81
82
        $stackOverflowJob->setLogo( null );
83
        $this->assertNull( $stackOverflowJob->getLogo() );
0 ignored issues
show
Bug introduced by
Are you sure the usage of $stackOverflowJob->getLogo() targeting Coco\SourceWatcher\Vendo...kOverflowJob::getLogo() 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...
84
    }
85
86
    /**
87
     *
88
     */
89
    public function testSetGetTitle () : void
90
    {
91
        $stackOverflowJob = new StackOverflowJob();
92
93
        $givenTitle = "Some Developer Role";
94
        $expectedTitle = "Some Developer Role";
95
96
        $stackOverflowJob->setTitle( $givenTitle );
97
        $this->assertNotNull( $stackOverflowJob->getTitle() );
98
        $this->assertEquals( $expectedTitle, $stackOverflowJob->getTitle() );
99
100
        $stackOverflowJob->setTitle( null );
101
        $this->assertNull( $stackOverflowJob->getTitle() );
0 ignored issues
show
Bug introduced by
Are you sure the usage of $stackOverflowJob->getTitle() targeting Coco\SourceWatcher\Vendo...OverflowJob::getTitle() 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...
102
    }
103
104
    /**
105
     *
106
     */
107
    public function testSetGetCompany () : void
108
    {
109
        $stackOverflowJob = new StackOverflowJob();
110
111
        $givenCompany = "Acme Corporation";
112
        $expectedCompany = "Acme Corporation";
113
114
        $stackOverflowJob->setCompany( $givenCompany );
115
        $this->assertNotNull( $stackOverflowJob->getCompany() );
116
        $this->assertEquals( $expectedCompany, $stackOverflowJob->getCompany() );
117
118
        $stackOverflowJob->setCompany( null );
119
        $this->assertNull( $stackOverflowJob->getCompany() );
0 ignored issues
show
Bug introduced by
Are you sure the usage of $stackOverflowJob->getCompany() targeting Coco\SourceWatcher\Vendo...erflowJob::getCompany() 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...
120
    }
121
122
    /**
123
     *
124
     */
125
    public function testSetGetLocation () : void
126
    {
127
        $stackOverflowJob = new StackOverflowJob();
128
129
        $givenLocation = "Saint Denis";
130
        $expectedLocation = "Saint Denis";
131
132
        $stackOverflowJob->setLocation( $givenLocation );
133
        $this->assertNotNull( $stackOverflowJob->getLocation() );
134
        $this->assertEquals( $expectedLocation, $stackOverflowJob->getLocation() );
135
136
        $stackOverflowJob->setLocation( null );
137
        $this->assertNull( $stackOverflowJob->getLocation() );
0 ignored issues
show
Bug introduced by
Are you sure the usage of $stackOverflowJob->getLocation() targeting Coco\SourceWatcher\Vendo...rflowJob::getLocation() 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...
138
    }
139
140
    /**
141
     *
142
     */
143
    public function testGetRefinedUrl () : void
144
    {
145
        $stackOverflowJob = new StackOverflowJob();
146
147
        // test full URL with query parameters
148
149
        $givenPreviewUrl = "https://stackoverflow.com/jobs/123456/some-developer-role?param1=a&param2=b&param3=c";
150
        $expectedPreviewUrl = "https://stackoverflow.com/jobs/123456/some-developer-role";
151
152
        $stackOverflowJob->setPreviewUrl( $givenPreviewUrl );
153
154
        $this->assertNotNull( $stackOverflowJob->getRefinedUrl() );
155
        $this->assertEquals( $expectedPreviewUrl, $stackOverflowJob->getRefinedUrl() );
156
157
        // test full URL
158
159
        $givenPreviewUrl = "https://stackoverflow.com/jobs/123456/some-developer-role";
160
        $expectedPreviewUrl = "https://stackoverflow.com/jobs/123456/some-developer-role";
161
162
        $stackOverflowJob->setPreviewUrl( $givenPreviewUrl );
163
164
        $this->assertNotNull( $stackOverflowJob->getRefinedUrl() );
165
        $this->assertEquals( $expectedPreviewUrl, $stackOverflowJob->getRefinedUrl() );
166
167
        // test partial URL with query parameters
168
169
        $givenPreviewUrl = "/jobs/123456/some-developer-role?param1=a&param2=b&param3=c";
170
        $expectedPreviewUrl = "https://stackoverflow.com/jobs/123456/some-developer-role";
171
172
        $stackOverflowJob->setPreviewUrl( $givenPreviewUrl );
173
174
        $this->assertNotNull( $stackOverflowJob->getRefinedUrl() );
175
        $this->assertEquals( $expectedPreviewUrl, $stackOverflowJob->getRefinedUrl() );
176
177
        // test partial URL
178
179
        $givenPreviewUrl = "/jobs/123456/some-developer-role";
180
        $expectedPreviewUrl = "https://stackoverflow.com/jobs/123456/some-developer-role";
181
182
        $stackOverflowJob->setPreviewUrl( $givenPreviewUrl );
183
184
        $this->assertNotNull( $stackOverflowJob->getRefinedUrl() );
185
        $this->assertEquals( $expectedPreviewUrl, $stackOverflowJob->getRefinedUrl() );
186
    }
187
}
188