1
exercism fetch php rail-fence-cipher

rail-fence-cipher_test.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
require_once "rail-fence-cipher.php";

class RailFenceCipherTest extends PHPUnit\Framework\TestCase
{

    /**
     * Test encode with two rails.
     */
    public function testEncodeWithTwoRails()
    {

        $plainText  = "XOXOXOXOXOXOXOXOXO";
        $rails = 2;
        $expected = "XXXXXXXXXOOOOOOOOO";
        $this->assertEquals(encode($plainText, $rails), $expected);
    }
    /**
     * Test encode with three rails.
     */
    public function testEncodeWithThreeRails()
    {
        $this->markTestSkipped();
        $plainText  = "WEAREDISCOVEREDFLEEATONCE";
        $rails = 3;
        $expected = "WECRLTEERDSOEEFEAOCAIVDEN";
        $this->assertEquals(encode($plainText, $rails), $expected);
    }

    /**
     * Test encode with ending in the middle.
     */
    public function testEncodeWithEndingInTheMiddle()
    {
        $this->markTestSkipped();
        $plainText  = "EXERCISES";
        $rails = 4;
        $expected = "ESXIEECSR";
        $this->assertEquals(encode($plainText, $rails), $expected);
    }

    /**
     * Test decode with three rails.
     */
    public function testDecodeWithThreeRails()
    {
        $this->markTestSkipped();
        $encryptedText  = "TEITELHDVLSNHDTISEIIEA";
        $rails = 3;
        $expected = "THEDEVILISINTHEDETAILS";
        $this->assertEquals(decode($encryptedText, $rails), $expected);
    }
    /**
     * Test decode with five rails.
     */
    public function testDecodeWithFiveRails()
    {
        $this->markTestSkipped();
        $encryptedText  = "EIEXMSMESAORIWSCE";
        $rails = 5;
        $expected = "EXERCISMISAWESOME";
        $this->assertEquals(decode($encryptedText, $rails), $expected);
    }

    /**
     * Test decode with six rails.
     */
    public function testDecodeWithSixRails()
    {
        $this->markTestSkipped();
        $encryptedText  = "133714114238148966225439541018335470986172518171757571896261";
        $rails = 6;
        $expected = "112358132134558914423337761098715972584418167651094617711286";
        $this->assertEquals(decode($encryptedText, $rails), $expected);
    }
}