Skip to content

Commit fe143ff

Browse files
peter279kAyesh
authored andcommitted
Test enhancement
1 parent 0430c7e commit fe143ff

File tree

2 files changed

+46
-45
lines changed

2 files changed

+46
-45
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ matrix:
33
include:
44
- php: 7.4
55
- php: 7.3
6+
- php: 7.2
67
- php: nightly
78
allow_failures:
8-
- php: nightly
9+
- php: nightly
910

1011
before_script:
1112
- composer self-update
12-
- travis_retry composer install --prefer-source --no-interaction --dev
13+
- travis_retry composer install --prefer-dist --no-interaction
1314
script:
1415
- composer test
1516
after_success:

tests/StrictTest.php

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@ class StrictTest extends TestCase {
99

1010
public function testEmptyArrayAccess() {
1111
$array = new Strict();
12-
self::assertFalse(isset($array[0]), 'Numeric key isset() should return false on an empty array.');
13-
self::assertFalse(isset($array['Foo']), 'Non-numeric key isset() should return false on an empty array.');
12+
$this->assertFalse(isset($array[0]), 'Numeric key isset() should return false on an empty array.');
13+
$this->assertFalse(isset($array['Foo']), 'Non-numeric key isset() should return false on an empty array.');
1414
}
1515

1616
public function testMixedCaseArrayGetValue() {
1717
$array = new Strict();
1818
$array['Foo'] = 'Bar';
1919

20-
self::assertNotEmpty($array['Foo'], 'Responded to the exact same key used to set the value.');
21-
self::assertNotEmpty($array['fOo'], 'Responded to mixed case array access.');
20+
$this->assertNotEmpty($array['Foo'], 'Responded to the exact same key used to set the value.');
21+
$this->assertNotEmpty($array['fOo'], 'Responded to mixed case array access.');
2222
}
2323

2424
public function testMixedCaseArraySetValue() {
2525
$array = new Strict();
2626
$array['Foo'] = 'Bar';
2727

28-
self::assertNotEmpty($array['Foo'], 'Responded to the exact same key used to set the value.');
28+
$this->assertNotEmpty($array['Foo'], 'Responded to the exact same key used to set the value.');
2929

3030
$array['fOO'] = 'baz';
31-
self::assertEquals('baz', $array['Foo'], 'Value was overwritten with mixed case value set.');
31+
$this->assertEquals('baz', $array['Foo'], 'Value was overwritten with mixed case value set.');
3232

3333
$array['FOO'] = 'Fred';
34-
self::assertEquals('Fred', $array['Foo'], 'Value was overwritten with mixed case value set.');
34+
$this->assertEquals('Fred', $array['Foo'], 'Value was overwritten with mixed case value set.');
3535
}
3636

3737
private static function getSampleTestArray() {
@@ -52,16 +52,16 @@ public function testInitializationWithArray() {
5252
$array = new Strict($source);
5353
$array[42] = 'Foo';
5454

55-
self::assertEquals('Fred', $array['Baz'], 'Array initialization with a source array, exact-key access success.');
56-
self::assertEquals('gARPly', $array['FoO'], 'Mixed case array initialization returns the same value.');
57-
self::assertSame(['Test' => 'Test2'], $array['QUX'], 'Array instantiate, array value matches.');
58-
self::assertSame(259394, $array[234], 'Numeric key returns exact same value with same type.');
59-
self::assertSame('Foo', $array[42], 'Numeric key returns exact same value with same type.');
55+
$this->assertEquals('Fred', $array['Baz'], 'Array initialization with a source array, exact-key access success.');
56+
$this->assertEquals('gARPly', $array['FoO'], 'Mixed case array initialization returns the same value.');
57+
$this->assertSame(['Test' => 'Test2'], $array['QUX'], 'Array instantiate, array value matches.');
58+
$this->assertSame(259394, $array[234], 'Numeric key returns exact same value with same type.');
59+
$this->assertSame('Foo', $array[42], 'Numeric key returns exact same value with same type.');
6060

6161
$array = new Strict();
6262
$array['x-frame-options'] = 'DENY';
6363
$array['X-FRAME-options'] = 'SAMEORIGIN';
64-
self::assertSame('SAMEORIGIN', $array['X-Frame-Options']);
64+
$this->assertSame('SAMEORIGIN', $array['X-Frame-Options']);
6565
}
6666

6767
public function testNumericArrayAccess() {
@@ -70,10 +70,10 @@ public function testNumericArrayAccess() {
7070
$array[] = 'Bar';
7171
$array[] = 'Fred';
7272

73-
self::assertEquals('Foo', $array[0]);
74-
self::assertEquals('Bar', $array['1']);
75-
self::assertEquals('Fred', $array[2]);
76-
self::assertNull($array[3]);
73+
$this->assertEquals('Foo', $array[0]);
74+
$this->assertEquals('Bar', $array['1']);
75+
$this->assertEquals('Fred', $array[2]);
76+
$this->assertNull($array[3]);
7777

7878
}
7979

@@ -84,8 +84,8 @@ public function testBasicArrayUnset() {
8484
$array['Fred'] = 14343;
8585
unset($array['fOO']);
8686

87-
self::assertNull($array['fOo'], 'Mixed case value unset call properly unset the value.');
88-
self::assertSame(14343, $array['FRED'], 'Mixed case value unset call maintained the container data.');
87+
$this->assertNull($array['fOo'], 'Mixed case value unset call properly unset the value.');
88+
$this->assertSame(14343, $array['FRED'], 'Mixed case value unset call maintained the container data.');
8989

9090
$source = [];
9191
$source[] = 'Zero';
@@ -95,54 +95,54 @@ public function testBasicArrayUnset() {
9595

9696
$array = new Strict($source);
9797

98-
self::assertSame('Zero', $array[0], 'Empty array [] operation key starts with zero.');
99-
self::assertSame('Two', $array[2]);
98+
$this->assertSame('Zero', $array[0], 'Empty array [] operation key starts with zero.');
99+
$this->assertSame('Two', $array[2]);
100100

101101
unset($array[1]);
102-
self::assertNull($array[1], 'Numeric key unset properly removes the value.');
102+
$this->assertNull($array[1], 'Numeric key unset properly removes the value.');
103103

104-
self::assertSame('Two', $array[2], 'Container is not reset on an unset() call.');
104+
$this->assertSame('Two', $array[2], 'Container is not reset on an unset() call.');
105105

106-
self::assertSame(4, $array['four'], 'Numeric and otherwise mixed key unset still work after unset calls.');
106+
$this->assertSame(4, $array['four'], 'Numeric and otherwise mixed key unset still work after unset calls.');
107107

108108
unset($array['FOur']);
109-
self::assertNull($array['FOUR'], 'Mixed case unset calls properly remove the values case insensitively.');
109+
$this->assertNull($array['FOUR'], 'Mixed case unset calls properly remove the values case insensitively.');
110110

111111
$array['foUR'] = 4;
112-
self::assertNotNull($array['FOUR']);
113-
self::assertSame(4, $array['fouR']);
112+
$this->assertNotNull($array['FOUR']);
113+
$this->assertSame(4, $array['fouR']);
114114
}
115115

116116
public function testCount() {
117117
$source = static::getSampleTestArray();
118118

119119
/**
120120
* Number unique case-insensitive keys in the sample array.
121-
* @see self::getSampleTestArray();
121+
* @see $this->getSampleTestArray();
122122
*/
123123
$source_count = 5;
124124

125125
$array = new Strict($source);
126126

127-
self::assertCount($source_count, $array, 'Initial count() call returns same values.');
127+
$this->assertCount($source_count, $array, 'Initial count() call returns same values.');
128128

129129
unset($array['FOo']);
130130
$source_count--;
131-
self::assertCount($source_count, $array);
131+
$this->assertCount($source_count, $array);
132132

133133
$array['FOO'] = 'Bar';
134134
$array['Foo'] = 'Bar';
135135
$array['foo'] = 'Bar';
136136
$array['FoO'] = 'Bar';
137137
$source_count++;
138-
self::assertCount($source_count, $array);
138+
$this->assertCount($source_count, $array);
139139

140140
$array[] = \rand(1, 100);
141141
$array[] = \rand(1, 100);
142142
$array[] = \rand(1, 100);
143143
$source_count += 3;
144144

145-
self::assertCount($source_count, $array);
145+
$this->assertCount($source_count, $array);
146146
}
147147

148148
public function testForeachIteration() {
@@ -156,10 +156,10 @@ public function testForeachIteration() {
156156

157157
// Check with the keys.
158158
foreach ($array as $key => $value) {
159-
self::assertEquals('foo', $key, 'Has overwritten the existing keys with the last key seen.');
160-
self::assertEquals('Bar', $value, 'Has overwritten the existing keys with the last key and its value.');
159+
$this->assertEquals('foo', $key, 'Has overwritten the existing keys with the last key seen.');
160+
$this->assertEquals('Bar', $value, 'Has overwritten the existing keys with the last key and its value.');
161161
if ($value === 'H') {
162-
self::assertEquals('Fred', $key, 'Key case is preserved.');
162+
$this->assertEquals('Fred', $key, 'Key case is preserved.');
163163
}
164164
}
165165

@@ -174,7 +174,7 @@ public function testForeachIteration() {
174174
// Check with the keys.
175175
foreach ($array as $key => $value) {
176176
if ($value === 'Bar') {
177-
self::assertEquals('FreD', $key, 'Key case is preserved.');
177+
$this->assertEquals('FreD', $key, 'Key case is preserved.');
178178
}
179179
}
180180

@@ -198,19 +198,19 @@ public function testCustomIteration() {
198198
];
199199

200200
$array = new Strict($source);
201-
self::assertEquals('Bar', $array->current());
202-
self::assertEquals('foo', $array->key());
201+
$this->assertEquals('Bar', $array->current());
202+
$this->assertEquals('foo', $array->key());
203203

204204
$array->next();
205-
self::assertNull($array->current());
206-
self::assertEquals('Nothing', $array->key());
205+
$this->assertNull($array->current());
206+
$this->assertEquals('Nothing', $array->key());
207207

208208
$array->rewind();
209-
self::assertEquals('Bar', $array->current());
210-
self::assertEquals('foo', $array->key());
209+
$this->assertEquals('Bar', $array->current());
210+
$this->assertEquals('foo', $array->key());
211211

212212
$array->next();
213-
self::assertFalse($array->valid());
213+
$this->assertFalse($array->valid());
214214
}
215215

216216
public function testDebugInfo() {

0 commit comments

Comments
 (0)