Passed
Push — main ( 0cf387...5995aa )
by Lorenzo
03:04
created

SuperCacheInvalidationHelperTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Padosoft\SuperCacheInvalidate\Test\Unit;
4
5
use PHPUnit\Framework\TestCase;
6
use Illuminate\Support\Facades\DB;
7
use Padosoft\SuperCacheInvalidate\Helpers\SuperCacheInvalidationHelper;
8
9
class SuperCacheInvalidationHelperTest extends TestCase
10
{
11
    protected SuperCacheInvalidationHelper $helper;
12
13
    protected function setUp(): void
14
    {
15
        parent::setUp();
16
        $this->helper = new SuperCacheInvalidationHelper();
17
    }
18
19
    public function testInsertInvalidationEvent(): void
20
    {
21
        // Mock DB insert
22
        DB::shouldReceive('table->insertGetId')->once()->andReturn(1);
23
24
        $this->helper->insertInvalidationEvent('tag', 'test_tag', 'Test reason', 0);
25
26
        // Assertions are handled by Mockery expectations
27
    }
28
29
    public function testInsertInvalidationEventWithAssociations(): void
30
    {
31
        // Mock DB insert
32
        DB::shouldReceive('table->insertGetId')->once()->andReturn(1);
33
        DB::shouldReceive('table->insert')->once();
34
35
        $this->helper->insertInvalidationEvent(
36
            'tag',
37
            'article_ID:7',
38
            'Article 7 removed',
39
            0,
40
            [
41
                ['type' => 'tag', 'identifier' => 'plp:sport'],
42
            ]
43
        );
44
45
        // Assertions are handled by Mockery expectations
46
    }
47
}
48