Completed
Pull Request — master (#13)
by Lhalaa
01:25
created

testPartialInvalidKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
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 PartialUserFormControllerFunctionalTest
11
 * @package Firesphere\PartialUserforms\Tests
12
 */
13
class PartialUserFormControllerFunctionalTest extends FunctionalTest
14
{
15
    /**
16
     * @var string
17
     */
18
    protected static $fixture_file = '../fixtures/partialformtest.yml';
19
20
    public function setUp()
21
    {
22
        parent::setUp();
23
24
        $this->objFromFixture(UserDefinedForm::class, 'form1')->publishRecursive();
25
    }
26
27
    public function testPartialPage()
28
    {
29
        $result = $this->get("partial");
30
        $this->assertEquals(404, $result->getStatusCode());
31
    }
32
33 View Code Duplication
    public function testPartialValidKeyToken()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
        $token = 'e6b27462211e1711';
36
        $key = singleton(PartialFormSubmission::class)->generateKey($token);
37
38
        $result = $this->get("partial/{$key}/{$token}");
39
        $this->assertEquals(200, $result->getStatusCode());
40
        $this->assertContains('Field 1', $result->getBody());
41
    }
42
43 View Code Duplication
    public function testPartialInvalidToken()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
    {
45
        $token = 'abcdef';
46
        $key = singleton(PartialFormSubmission::class)->generateKey($token);
47
48
        $result = $this->get("partial/{$key}/{$token}");
49
        $this->assertEquals(404, $result->getStatusCode());
50
    }
51
52
    public function testPartialInvalidKey()
53
    {
54
        $token = 'e6b27462211e1711';
55
        $key = 'abcdef';
56
57
        $result = $this->get("partial/{$key}/{$token}");
58
        $this->assertEquals(404, $result->getStatusCode());
59
60
        $token = 'qwerty';
61
        $key = 'abcdef';
62
63
        $result = $this->get("partial/{$key}/{$token}");
64
        $this->assertEquals(404, $result->getStatusCode());
65
    }
66
}
67