-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAdditionalTrackerTest.php
More file actions
40 lines (31 loc) · 1.07 KB
/
AdditionalTrackerTest.php
File metadata and controls
40 lines (31 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace Thoughtco\StatamicCacheTracker\Tests\Unit;
use PHPUnit\Framework\Attributes\Test;
use Thoughtco\StatamicCacheTracker\Facades\Tracker;
use Thoughtco\StatamicCacheTracker\Tests\TestCase;
class AdditionalTrackerTest extends TestCase
{
#[Test]
public function tracks_additional_closures()
{
Tracker::addAdditionalTracker(function ($tracker, $next) {
$tracker->addContentTag('test::tag');
});
$this->get('/');
$this->assertSame(['test::tag', 'pages:home', 'collection:pages'], collect(Tracker::all())->firstWhere('url', 'http://localhost')['tags']);
}
#[Test]
public function tracks_additional_classes()
{
Tracker::addAdditionalTracker(AdditionalTrackerClass::class);
$this->get('/');
$this->assertSame(['additional::tag', 'pages:home', 'collection:pages'], collect(Tracker::all())->firstWhere('url', 'http://localhost')['tags']);
}
}
class AdditionalTrackerClass
{
public function __invoke($tracker, $next)
{
$tracker->addContentTag('additional::tag');
}
}