Completed
Push — release/php7.2 ( 6615a6...2f8b7e )
by Grant
22:23 queued 16:18
created

JobPosterTest::testJobPosterIsOpen()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Tests\Unit;
4
5
use Tests\TestCase;
6
use Illuminate\Foundation\Testing\WithFaker;
7
use Illuminate\Foundation\Testing\RefreshDatabase;
8
use Illuminate\Support\Facades\Lang;
9
10
use App\Models\JobPoster;
11
12
class JobPosterTest extends TestCase
13
{
14
    use WithFaker;
15
16
    /**
17
     * Test that JobPoster->isOpen() behaves properly
18
     *
19
     * @return void
20
     */
21
    public function testJobPosterIsOpen()
22
    {
23
        $jobPoster = factory(JobPoster::class)->states('published')->make();
24
        $this->assertTrue($jobPoster->isOpen());
25
26
        $jobPoster->close_date_time = $this->faker->dateTimeBetween('-1 weeks', 'now');
27
        $this->assertFalse($jobPoster->isOpen());
28
29
        $jobPoster = factory(JobPoster::class)->states('unpublished')->make();
30
        $this->assertFalse($jobPoster->isOpen());
31
    }
32
33
    /**
34
     * Test that JobPoster->timeRemaining() behaves properly
35
     *
36
     * @return void
37
     */
38
    public function testJobPosterTimeRemaining()
39
    {
40
        $jobPoster = factory(JobPoster::class)->make(
41
            [
42
                'close_date_time' => date('Y-m-d H:i:s', strtotime('-1 hour'))
43
            ]
44
        );
45
        $this->assertEquals(Lang::choice('common/time.hour', 1), $jobPoster->timeRemaining());
46
47
        $jobPoster = factory(JobPoster::class)->make(
48
            [
49
                'close_date_time' => date('Y-m-d H:i:s', strtotime('-2 days'))
50
            ]
51
        );
52
        $langString = Lang::choice('common/time.day', 2);
53
        $this->assertEquals($langString, $jobPoster->timeRemaining());
54
    }
55
}
56