Completed
Push — master ( 3eba7c...0a67a0 )
by Simon
15s queued 11s
created

testPartialInvalidToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Firesphere\PartialUserforms\Tests;
4
5
use Firesphere\PartialUserforms\Models\PartialFormSubmission;
6
use SilverStripe\Dev\FunctionalTest;
7
use SilverStripe\UserForms\Model\UserDefinedForm;
8
9
/**
10
 * Class PartialUserFormControllerTest
11
 * @package Firesphere\PartialUserforms\Tests
12
 */
13
class PartialUserFormControllerTest extends FunctionalTest
14
{
15
    /**
16
     * @var string
17
     */
18
    protected static $fixture_file = '../fixtures/partialformtest.yml';
19
20
    public function testPartialPage()
21
    {
22
        $result = $this->get("partial");
23
        $this->assertEquals(404, $result->getStatusCode());
24
    }
25
26
    /**
27
     * @todo
28
     */
29
    public function testPartialValidKeyToken()
30
    {
31
        $this->markTestSkipped('Revisit and set up themes for testing');
32
33
        $token = 'q1w2e3r4t5y6u7i8';
34
        // No Parent
35
        $key = singleton(PartialFormSubmission::class)->generateKey($token);
36
        $result = $this->get("partial/{$key}/{$token}");
37
        $this->assertEquals(404, $result->getStatusCode());
38
39
        // Partial with UserDefinedForm
40
        $key = $this->objFromFixture(PartialFormSubmission::class, 'submission1')->generateKey($token);
41
        $result = $this->get("partial/{$key}/{$token}");
42
        $this->assertEquals(200, $result->getStatusCode());
43
        $this->assertContains('Field 1', $result->getBody());
44
    }
45
46
    public function testPartialInvalidToken()
47
    {
48
        $token = 'abcdef';
49
        $key = singleton(PartialFormSubmission::class)->generateKey($token);
50
51
        $result = $this->get("partial/{$key}/{$token}");
52
        $this->assertEquals(404, $result->getStatusCode());
53
    }
54
55
    public function testPartialInvalidKey()
56
    {
57
        $token = 'e6b27462211e1711';
58
        $key = 'abcdef';
59
60
        $result = $this->get("partial/{$key}/{$token}");
61
        $this->assertEquals(404, $result->getStatusCode());
62
63
        $token = 'qwerty';
64
        $key = 'abcdef';
65
66
        $result = $this->get("partial/{$key}/{$token}");
67
        $this->assertEquals(404, $result->getStatusCode());
68
    }
69
70
    public function setUp()
71
    {
72
        parent::setUp();
73
        $this->objFromFixture(UserDefinedForm::class, 'form1')->publishRecursive();
74
    }
75
}
76