1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Dynamic\Jobs\Test\Page; |
4
|
|
|
|
5
|
|
|
use Dynamic\Jobs\Page\Job; |
6
|
|
|
use Dynamic\Jobs\Page\JobController; |
7
|
|
|
use Dynamic\Jobs\Page\JobCollection; |
8
|
|
|
use SilverStripe\Control\HTTPResponse; |
9
|
|
|
use SilverStripe\Core\Injector\Injector; |
10
|
|
|
use SilverStripe\Dev\FunctionalTest; |
11
|
|
|
use SilverStripe\Forms\Form; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class JobControllerTest |
15
|
|
|
* @package Dynamic\Jobs\Tests |
16
|
|
|
*/ |
17
|
|
|
class JobControllerTest extends FunctionalTest |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
protected static $fixture_file = '../fixtures.yml'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var bool |
26
|
|
|
*/ |
27
|
|
|
protected static $use_draft_site = true; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Tests apply() |
31
|
|
|
*/ |
32
|
|
|
public function testApply() |
33
|
|
|
{ |
34
|
|
|
/** @var Job $object */ |
35
|
|
|
$object = $this->objFromFixture(Job::class, 'one'); |
36
|
|
|
$link = $object->Link('apply'); |
37
|
|
|
|
38
|
|
|
$page = $this->get($link); |
39
|
|
|
$this->assertInstanceOf(HttpResponse::class, $page); |
40
|
|
|
$this->assertEquals(200, $page->getStatusCode()); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Tests JobApp() |
45
|
|
|
*/ |
46
|
|
|
public function testJobApp() |
47
|
|
|
{ |
48
|
|
|
/** @var JobController $object */ |
49
|
|
|
$object = Injector::inst()->create(JobController::class); |
50
|
|
|
$form = $object->JobApp(); |
51
|
|
|
|
52
|
|
|
$this->assertInstanceOf(Form::class, $form); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Tests doApply() |
57
|
|
|
*/ |
58
|
|
|
public function testDoApply() |
59
|
|
|
{ |
60
|
|
|
$this->autoFollowRedirection = false; |
61
|
|
|
$this->clearEmails(); |
62
|
|
|
|
63
|
|
|
$this->objFromFixture(JobCollection::class, 'default'); |
64
|
|
|
/** @var Job $object */ |
65
|
|
|
$object = $this->objFromFixture(Job::class, 'open'); |
66
|
|
|
|
67
|
|
|
$this->get($object->Link('apply')); |
68
|
|
|
$page = $this->post($object->Link('JobApp'), [ |
69
|
|
|
'FirstName' => 'Eric', |
70
|
|
|
'LastName' => 'Praline', |
71
|
|
|
'Email' => '[email protected]', |
72
|
|
|
'Phone' => '444-555-6666', |
73
|
|
|
'Resume' => null, |
74
|
|
|
]); |
75
|
|
|
|
76
|
|
|
// $this->assertEmailSent('[email protected]'); |
|
|
|
|
77
|
|
|
|
78
|
|
|
$this->assertInstanceOf(HttpResponse::class, $page); |
79
|
|
|
$this->assertEquals(302, $page->getStatusCode()); |
80
|
|
|
|
81
|
|
|
$this->clearEmails(); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Tests complete() |
86
|
|
|
*/ |
87
|
|
|
public function testComplete() |
88
|
|
|
{ |
89
|
|
|
/** @var Job $object */ |
90
|
|
|
$object = $this->objFromFixture(Job::class, 'open'); |
91
|
|
|
$page = $this->get($object->Link('complete')); |
92
|
|
|
|
93
|
|
|
$this->assertInstanceOf(HttpResponse::class, $page); |
94
|
|
|
$this->assertEquals(200, $page->getStatusCode()); |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.