Skip to content

Commit 2cc2256

Browse files
committed
Add some helper tests
1 parent fa8edd1 commit 2cc2256

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
"Codebarista\\LaravelEssentials\\Tests\\": "tests/"
4343
}
4444
},
45+
"scripts": {
46+
"test": "./vendor/bin/pest"
47+
},
4548
"extra": {
4649
"laravel": {
4750
"providers": [

tests/Feature/HelpersTest.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<?php
22

3+
it('has the callable helpers', function () {
4+
expect('encode_json')->toBeCallable()
5+
->and('decode_json')->toBeCallable()
6+
->and('crush_png')->toBeCallable()
7+
->and('str_chop')->toBeCallable();
8+
});
9+
310
it('decodes json string to array', function () {
411
$value = <<<'JSON'
512
{
@@ -26,23 +33,18 @@
2633
})->covers('encode_json');
2734

2835
it('chops a string', function () {
29-
$value = Str::random(42);
30-
31-
expect(str_chop($value, 20))
36+
expect(str_chop(md5(microtime()), 20))
3237
->toBeString()
3338
->toContain('...')
3439
->toHaveLength(23);
3540

3641
})->covers('str_chop');
3742

38-
//it('can crush png', function () {
39-
// $version = null;
40-
//
41-
// if ($pngcrush = exec('which pngcrush')) {
42-
// $version = exec($pngcrush.' --version');
43-
// }
44-
//
45-
// expect($version)->toBeString();
46-
// // ->toContain('pngcrush');
47-
//
48-
//})->covers('crush_png');
43+
it('has pngcrush installed', function () {
44+
exec(' LC_ALL=C type pngcrush', $output, $result);
45+
expect($output)
46+
->toBeArray()
47+
->and($result)
48+
->toBeInt()
49+
->toBe(0);
50+
});

0 commit comments

Comments
 (0)