Completed
Push — master ( dca8df...f539eb )
by Yaro
04:25
created

AbstractFieldTest::default_width()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Yaro\Jarboe\Tests\Fields;
4
5
use Yaro\Jarboe\Table\Fields\AbstractField;
6
use Yaro\Jarboe\Tests\AbstractBaseTest;
7
8
abstract class AbstractFieldTest extends AbstractBaseTest
9
{
10
    const NAME = 'name';
11
    const TITLE_FROM_NAME = 'Name';
12
    const TITLE = 'Title';
13
    const ANOTHER_NAME = 'another';
14
    const ANOTHER_TITLE = 'Another';
15
16
    abstract protected function getFieldWithName(): AbstractField;
17
    abstract protected function getFieldWithNameAndTitle(): AbstractField;
18
19
    protected function field(): AbstractField
20
    {
21
        return $this->getFieldWithName();
22
    }
23
24
    /**
25
     * @test
26
     */
27
    public function title_generated_from_name()
28
    {
29
        $field = $this->getFieldWithName();
30
31
        $this->assertEquals(self::TITLE_FROM_NAME, $field->title());
32
    }
33
34
    /**
35
     * @test
36
     */
37
    public function title_not_generated_from_name()
38
    {
39
        $field = $this->getFieldWithNameAndTitle();
40
41
        $this->assertEquals(self::TITLE, $field->title());
42
    }
43
44
    /**
45
     * @test
46
     */
47
    public function title_redefined()
48
    {
49
        $field = $this->getFieldWithNameAndTitle()->title(self::ANOTHER_TITLE);
50
51
        $this->assertEquals(self::ANOTHER_TITLE, $field->title());
52
    }
53
54
    /**
55
     * @test
56
     */
57
    public function title_not_generated_after_name_change()
58
    {
59
        $field = $this->getFieldWithNameAndTitle()->name(self::ANOTHER_NAME);
60
61
        $this->assertEquals(self::TITLE, $field->title());
62
    }
63
64
    /**
65
     * @test
66
     */
67
    public function default_col_width()
68
    {
69
        $field = $this->field();
70
71
        $this->assertEquals(12, $field->getCol());
72
    }
73
74
    /**
75
     * @test
76
     */
77
    public function changed_col_width()
78
    {
79
        $field = $this->field()->col(4);
80
81
        $this->assertEquals(4, $field->getCol());
82
    }
83
84
    /**
85
     * @test
86
     */
87
    public function default_width()
88
    {
89
        $field = $this->field();
90
91
        $this->assertNull($field->getWidth());
92
    }
93
94
    /**
95
     * @test
96
     */
97
    public function changed_width()
98
    {
99
        $field = $this->field()->width(40);
100
101
        $this->assertEquals(40, $field->getWidth());
102
    }
103
104
    /**
105
     * @test
106
     */
107
    public function default_tab()
108
    {
109
        $field = $this->field();
110
111
        $this->assertEquals(AbstractField::DEFAULT_TAB_IDENT, $field->getTab());
112
    }
113
114
    /**
115
     * @test
116
     */
117
    public function changed_tab()
118
    {
119
        $field = $this->field()->tab('tab');
120
121
        $this->assertEquals('tab', $field->getTab());
122
    }
123
124
    /**
125
     * @test
126
     */
127
    public function default_default_value()
128
    {
129
        $field = $this->field();
130
131
        $this->assertNull($field->getDefault());
132
    }
133
134
    /**
135
     * @test
136
     */
137
    public function changed_default_value()
138
    {
139
        $field = $this->field()->default('default value');
140
141
        $this->assertEquals('default value', $field->getDefault());
142
    }
143
144
    /**
145
     * @test
146
     */
147
    public function default_readonly()
148
    {
149
        $field = $this->field();
150
151
        $this->assertFalse($field->isReadonly());
152
    }
153
154
    /**
155
     * @test
156
     */
157
    public function changed_readonly()
158
    {
159
        $field = $this->field()->readonly();
160
161
        $this->assertTrue($field->isReadonly());
162
    }
163
164
    /**
165
     * @test
166
     */
167
    public function default_inline()
168
    {
169
        $field = $this->field();
170
171
        $this->assertFalse($field->isInline());
172
    }
173
}
174