aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/lib/classes/ButtonTest.php
blob: 5ed16b719f7ca897cccd356a41ea8d3b05ba7917 (plain)
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
<?php

/*
 * Copyright (C) 2011 - <mlunzena@uos.de>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 */

use \Studip\Button;

class ButtonTestCase extends \Codeception\Test\Unit
{
    function testCreate()
    {
        $this->assertEquals('<button type="submit" class="button" name="ok">ok</button>', '' . Button::create());
    }

    function testCreateWithLabel()
    {
        $this->assertEquals('<button type="submit" class="button" name="yes">yes</button>', '' . Button::create('yes'));
    }

    function testCreateWithLabelAndString()
    {
        $this->assertEquals('<button type="submit" class="button" name="aName">yes</button>', '' . Button::create('yes', 'aName'));
    }

    function testCreateWithLabelAndArray()
    {
        $this->assertEquals('<button type="submit" a="1" b="2" class="button" name="yes">yes</button>',
                            '' . Button::create('yes', ['a' => 1, 'b' => 2]));
    }

    function testCreateWithLabelNameAndArray()
    {
        $this->assertEquals('<button type="submit" a="1" b="2" class="button" name="aName">yes</button>',
                            '' . Button::create('yes', 'aName', ['a' => 1, 'b' => 2]));
    }

    function testCreateAccept()
    {
        $this->assertEquals('<button type="submit" class="accept button" name="accept">Übernehmen</button>',
                            '' . Button::createAccept());
    }

    function testCreateCancel()
    {
        $this->assertEquals('<button type="submit" class="cancel button" name="cancel">Abbrechen</button>',
                            '' . Button::createCancel());
    }

    function testCreatePreOrder()
    {
        $this->assertEquals('<button type="submit" class="pre-order button" name="pre-order">ok</button>',
                            '' . Button::createPreOrder());
    }

    function testCreateWithInsaneArguments()
    {
        $this->assertEquals('<button type="submit" class="button" mad="&lt;S&gt;tu&quot;ff" name="m&amp;m">&gt;ok&lt;</button>',
                            '' . Button::create('>ok<', 'm&m', ['mad' => '<S>tu"ff']));
    }
}