Skip to content

Commit 1bd5f2f

Browse files
committed
tests: improved descriptions
1 parent 577fc6a commit 1bd5f2f

32 files changed

+187
-187
lines changed

tests/Iterators/CachingIterator.basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use Tester\Assert;
1313
require __DIR__ . '/../bootstrap.php';
1414

1515

16-
test('Two items in array', function () {
16+
test('two items in array', function () {
1717
$arr = ['Nette', 'Framework'];
1818

1919
$iterator = new Iterators\CachingIterator($arr);

tests/Iterators/CachingIterator.construct.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ test('stdClass', function () {
4141
});
4242

4343

44-
test('IteratorAggregate', function () {
44+
test('iteratorAggregate', function () {
4545
$arr = new ArrayObject(['Nette', 'Framework']);
4646
$tmp = [];
4747
foreach (new Iterators\CachingIterator($arr) as $k => $v) {
@@ -54,7 +54,7 @@ test('IteratorAggregate', function () {
5454
], $tmp);
5555
});
5656

57-
test('Iterator', function () {
57+
test('iterator', function () {
5858
$arr = new ArrayObject(['Nette', 'Framework']);
5959
$tmp = [];
6060
foreach (new Iterators\CachingIterator($arr->getIterator()) as $k => $v) {
@@ -68,7 +68,7 @@ test('Iterator', function () {
6868
});
6969

7070

71-
test('SimpleXMLElement', function () {
71+
test('simpleXMLElement', function () {
7272
$arr = new SimpleXMLElement('<feed><item>Nette</item><item>Framework</item></feed>');
7373
$tmp = [];
7474
foreach (new Iterators\CachingIterator($arr) as $k => $v) {

tests/Utils/ArrayHash.phpt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Person
3131
}
3232

3333

34-
test('', function () {
34+
test('store and retrieve values via array and property notation', function () {
3535
$list = new ArrayHash;
3636
$jack = new Person('Jack');
3737
$mary = new Person('Mary');
@@ -79,7 +79,7 @@ test('', function () {
7979
});
8080

8181

82-
test('', function () {
82+
test('creation with non‐recursive conversion leaves nested arrays unchanged', function () {
8383
$mary = new Person('Mary');
8484
$list = ArrayHash::from([
8585
'm' => $mary,
@@ -93,7 +93,7 @@ test('', function () {
9393
});
9494

9595

96-
test('', function () {
96+
test('recursive conversion transforms nested arrays into ArrayHash', function () {
9797
$mary = new Person('Mary');
9898
$list = ArrayHash::from([
9999
'm' => $mary,
@@ -121,7 +121,7 @@ test('', function () {
121121
});
122122

123123

124-
test('numeric fields', function () {
124+
test('numeric key handling supports both integer and string offsets', function () {
125125
$row = ArrayHash::from([1, 2]);
126126

127127
foreach ($row as $key => $value) {
@@ -171,7 +171,7 @@ test('numeric fields', function () {
171171
});
172172

173173

174-
test('null fields', function () {
174+
test('null values are stored but not regarded as set', function () {
175175
$row = ArrayHash::from(['null' => null]);
176176
Assert::null($row->null);
177177
Assert::null($row['null']);
@@ -180,7 +180,7 @@ test('null fields', function () {
180180
});
181181

182182

183-
test('undeclared fields', function () {
183+
test('accessing undefined keys triggers a notice or warning', function () {
184184
$row = new ArrayHash;
185185
Assert::error(
186186
fn() => $row->undef,
@@ -196,7 +196,7 @@ test('undeclared fields', function () {
196196
});
197197

198198

199-
test('PHP 7 changed behavior https://3v4l.org/2A1pf', function () {
199+
test('unsetting entries during iteration removes them', function () {
200200
$hash = ArrayHash::from([1, 2, 3]);
201201
foreach ($hash as $key => $value) {
202202
unset($hash->$key);
@@ -206,7 +206,7 @@ test('PHP 7 changed behavior https://3v4l.org/2A1pf', function () {
206206
});
207207

208208

209-
test('iteration with reference', function () {
209+
test('reference iteration allows modification of all elements', function () {
210210
$hash = ArrayHash::from([1, 2, 3]);
211211
foreach ($hash as $key => &$value) {
212212
$value = 'new';

tests/Utils/ArrayList.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Person
3131
}
3232

3333

34-
test('ArrayList::from', function () {
34+
test('creation from valid list and error on associative arrays', function () {
3535
Assert::exception(
3636
fn() => ArrayList::from(['a' => 1, 'b' => 2]),
3737
Nette\InvalidArgumentException::class,
@@ -46,7 +46,7 @@ test('ArrayList::from', function () {
4646
});
4747

4848

49-
test('', function () {
49+
test('supports push, access, iteration, unset, and prepend operations', function () {
5050
$list = new ArrayList;
5151
$jack = new Person('Jack');
5252
$mary = new Person('Mary');
@@ -90,7 +90,7 @@ test('', function () {
9090
});
9191

9292

93-
test('', function () {
93+
test('setting invalid offsets throws OutOfRangeException', function () {
9494
$list = new ArrayList;
9595
$list[] = 'a';
9696
$list[] = 'b';
@@ -115,7 +115,7 @@ test('', function () {
115115
});
116116

117117

118-
test('', function () {
118+
test('accessing invalid offsets throws OutOfRangeException', function () {
119119
$list = new ArrayList;
120120
$list[] = 'a';
121121
$list[] = 'b';
@@ -140,7 +140,7 @@ test('', function () {
140140
});
141141

142142

143-
test('', function () {
143+
test('unsetting invalid offsets throws OutOfRangeException', function () {
144144
$list = new ArrayList;
145145
$list[] = 'a';
146146
$list[] = 'b';
@@ -159,7 +159,7 @@ test('', function () {
159159
});
160160

161161

162-
test('iteration with reference', function () {
162+
test('reference iteration modifies all list elements', function () {
163163
$list = ArrayList::from([1, 2, 3]);
164164
foreach ($list as $key => &$value) {
165165
$value = 'new';

tests/Utils/Arrays.every().phpt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use Tester\Assert;
1313
require __DIR__ . '/../bootstrap.php';
1414

1515

16-
test('', function () {
16+
test('empty array returns true without iteration', function () {
1717
$arr = [];
1818
$log = [];
1919
$res = Arrays::every(
@@ -27,7 +27,7 @@ test('', function () {
2727
Assert::same([], $log);
2828
});
2929

30-
test('', function () {
30+
test('empty array returns true regardless of callback result', function () {
3131
$arr = [];
3232
$log = [];
3333
$res = Arrays::every(
@@ -41,7 +41,7 @@ test('', function () {
4141
Assert::same([], $log);
4242
});
4343

44-
test('', function () {
44+
test('iteration stops on first false predicate', function () {
4545
$arr = ['a', 'b'];
4646
$log = [];
4747
$res = Arrays::every(
@@ -55,7 +55,7 @@ test('', function () {
5555
Assert::same([['a', 0, $arr]], $log);
5656
});
5757

58-
test('', function () {
58+
test('all elements satisfying predicate return true', function () {
5959
$arr = ['a', 'b'];
6060
$log = [];
6161
$res = Arrays::every(
@@ -69,7 +69,7 @@ test('', function () {
6969
Assert::same([['a', 0, $arr], ['b', 1, $arr]], $log);
7070
});
7171

72-
test('', function () {
72+
test('not all elements satisfying predicate return false', function () {
7373
$arr = ['a', 'b'];
7474
$log = [];
7575
$res = Arrays::every(
@@ -83,7 +83,7 @@ test('', function () {
8383
Assert::same([['a', 0, $arr], ['b', 1, $arr]], $log);
8484
});
8585

86-
test('', function () {
86+
test('associative array iteration preserves key order in callback', function () {
8787
$arr = ['x' => 'a', 'y' => 'b'];
8888
$log = [];
8989
$res = Arrays::every(
@@ -97,7 +97,7 @@ test('', function () {
9797
Assert::same([['a', 'x', $arr], ['b', 'y', $arr]], $log);
9898
});
9999

100-
test('', function () {
100+
test('works seamlessly with Traversable objects', function () {
101101
$arr = new ArrayIterator(['x' => 'a', 'y' => 'b']);
102102
$log = [];
103103
$res = Arrays::every(

tests/Utils/Arrays.get().phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $arr = [
2121
],
2222
];
2323

24-
test('Single item', function () use ($arr) {
24+
test('basic retrieval with default and exception for missing keys', function () use ($arr) {
2525
Assert::same('first', Arrays::get($arr, ''));
2626
Assert::same('second', Arrays::get($arr, 1));
2727
Assert::same('second', Arrays::get($arr, 1, 'x'));
@@ -34,7 +34,7 @@ test('Single item', function () use ($arr) {
3434
});
3535

3636

37-
test('Traversing', function () use ($arr) {
37+
test('nested access using key path', function () use ($arr) {
3838
Assert::same([
3939
'' => 'first',
4040
1 => 'second',

tests/Utils/Arrays.getRef().phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $arr = [
2121
],
2222
];
2323

24-
test('Single item', function () use ($arr) {
24+
test('reference update and auto-add missing key', function () use ($arr) {
2525
$dolly = $arr;
2626
$item = &Arrays::getRef($dolly, '');
2727
$item = 'changed';
@@ -48,7 +48,7 @@ test('Single item', function () use ($arr) {
4848
});
4949

5050

51-
test('Traversing', function () use ($arr) {
51+
test('nested reference assignment and full array override', function () use ($arr) {
5252
$dolly = $arr;
5353
$item = &Arrays::getRef($dolly, []);
5454
$item = 'changed';
@@ -68,7 +68,7 @@ test('Traversing', function () use ($arr) {
6868
});
6969

7070

71-
test('Error', function () use ($arr) {
71+
test('exception on invalid nested reference', function () use ($arr) {
7272
$dolly = $arr;
7373
Assert::exception(
7474
fn() => $item = &Arrays::getRef($dolly, [7, 'item', 3]),

tests/Utils/Arrays.insertBefore().phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $arr = [
2121
];
2222

2323

24-
test('First item', function () use ($arr) {
24+
test('first item', function () use ($arr) {
2525
$dolly = $arr;
2626
Arrays::insertBefore($dolly, null, ['new' => 'value']);
2727
Assert::same([
@@ -45,7 +45,7 @@ test('First item', function () use ($arr) {
4545
});
4646

4747

48-
test('Last item', function () use ($arr) {
48+
test('last item', function () use ($arr) {
4949
$dolly = $arr;
5050
Arrays::insertBefore($dolly, 7, ['new' => 'value']);
5151
Assert::same([
@@ -69,7 +69,7 @@ test('Last item', function () use ($arr) {
6969
});
7070

7171

72-
test('Undefined item', function () use ($arr) {
72+
test('undefined item', function () use ($arr) {
7373
$dolly = $arr;
7474
Arrays::insertBefore($dolly, 'undefined', ['new' => 'value']);
7575
Assert::same([

tests/Utils/Arrays.pick().phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $arr = [
1919
2 => 'second',
2020
];
2121

22-
test('Single item', function () use ($arr) {
22+
test('single item', function () use ($arr) {
2323
Assert::same('null', Arrays::pick($arr, ''));
2424
Assert::same('first', Arrays::pick($arr, 1));
2525
Assert::same('x', Arrays::pick($arr, 1, 'x'));

tests/Utils/Arrays.some().phpt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use Tester\Assert;
1313
require __DIR__ . '/../bootstrap.php';
1414

1515

16-
test('', function () {
16+
test('empty array returns false without iteration', function () {
1717
$arr = [];
1818
$log = [];
1919
$res = Arrays::some(
@@ -27,7 +27,7 @@ test('', function () {
2727
Assert::same([], $log);
2828
});
2929

30-
test('', function () {
30+
test('empty array always fails some condition', function () {
3131
$arr = [];
3232
$log = [];
3333
$res = Arrays::some(
@@ -41,7 +41,7 @@ test('', function () {
4141
Assert::same([], $log);
4242
});
4343

44-
test('', function () {
44+
test('all elements failing predicate result in false', function () {
4545
$arr = ['a', 'b'];
4646
$log = [];
4747
$res = Arrays::some(
@@ -55,7 +55,7 @@ test('', function () {
5555
Assert::same([['a', 0, $arr], ['b', 1, $arr]], $log);
5656
});
5757

58-
test('', function () {
58+
test('iteration stops on first true predicate', function () {
5959
$arr = ['a', 'b'];
6060
$log = [];
6161
$res = Arrays::some(
@@ -69,7 +69,7 @@ test('', function () {
6969
Assert::same([['a', 0, $arr]], $log);
7070
});
7171

72-
test('', function () {
72+
test('some element satisfying predicate returns true', function () {
7373
$arr = ['a', 'b'];
7474
$log = [];
7575
$res = Arrays::some(
@@ -83,7 +83,7 @@ test('', function () {
8383
Assert::same([['a', 0, $arr]], $log);
8484
});
8585

86-
test('', function () {
86+
test('works with associative arrays to identify a matching element', function () {
8787
$arr = ['x' => 'a', 'y' => 'b'];
8888
$log = [];
8989
$res = Arrays::some(
@@ -97,7 +97,7 @@ test('', function () {
9797
Assert::same([['a', 'x', $arr]], $log);
9898
});
9999

100-
test('', function () {
100+
test('works with Traversable objects in some method', function () {
101101
$arr = new ArrayIterator(['x' => 'a', 'y' => 'b']);
102102
$log = [];
103103
$res = Arrays::some(

0 commit comments

Comments
 (0)