Add an initial test for counting past talks
This commit is contained in:
parent
8a05b19fd4
commit
26a632608b
|
@ -10,6 +10,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
|
"illuminate/collections": "^8.55",
|
||||||
"opdavies/sculpin-gist-embed-bundle": "^0.1.0",
|
"opdavies/sculpin-gist-embed-bundle": "^0.1.0",
|
||||||
"opdavies/sculpin-twig-markdown-bundle": "^0.2.0",
|
"opdavies/sculpin-twig-markdown-bundle": "^0.2.0",
|
||||||
"sculpin/sculpin": "^3.0"
|
"sculpin/sculpin": "^3.0"
|
||||||
|
@ -22,5 +23,18 @@
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"sort-packages": true
|
"sort-packages": true
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^9.5"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"App\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"App\\Tests\\": "tests/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2216
composer.lock
generated
2216
composer.lock
generated
File diff suppressed because it is too large
Load diff
17
src/TwigExtension/TalkExtension.php
Normal file
17
src/TwigExtension/TalkExtension.php
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\TwigExtension;
|
||||||
|
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
final class TalkExtension
|
||||||
|
{
|
||||||
|
public function getPastTalksCount(array $talks = []): int
|
||||||
|
{
|
||||||
|
$talkCollection = new Collection($talks);
|
||||||
|
|
||||||
|
return $talkCollection->count();
|
||||||
|
}
|
||||||
|
}
|
15
tests/TalkExtensionTest.php
Normal file
15
tests/TalkExtensionTest.php
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Tests;
|
||||||
|
|
||||||
|
use App\TwigExtension\TalkExtension;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
final class TalkExtensionTest extends TestCase
|
||||||
|
{
|
||||||
|
/** @test */
|
||||||
|
public function it_returns_zero_if_there_are_no_talks(): void
|
||||||
|
{
|
||||||
|
$this->assertSame(0, (new TalkExtension())->getPastTalksCount([]));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue