• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

RonasIT / laravel-helpers / 14260163152

04 Apr 2025 07:20AM UTC coverage: 77.591% (-1.5%) from 79.092%
14260163152

Pull #111

github

web-flow
Merge 630f28118 into 38fbefe16
Pull Request #111: #98 assertEqualsFixture add reference to assertable fixture to error message

7 of 7 new or added lines in 1 file covered. (100.0%)

34 existing lines in 2 files now uncovered.

1108 of 1428 relevant lines covered (77.59%)

12.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

5.0
/src/Testing/TestCase.php
1
<?php
2

3
namespace RonasIT\Support\Testing;
4

5
use Carbon\Carbon;
6
use Illuminate\Foundation\Testing\TestCase as BaseTest;
7
use Illuminate\Support\Facades\DB;
8
use Illuminate\Support\Facades\Mail;
9
use Illuminate\Testing\TestResponse;
10
use RonasIT\Support\Traits\MailsMockTrait;
11

12
abstract class TestCase extends BaseTest
13
{
14
    use MailsMockTrait;
15

16
    protected $auth;
17

18
    protected string $testNow = '2018-11-11 11:11:11';
19

20
    protected static string $startedTestSuite = '';
21
    protected static bool $isWrappedIntoTransaction = true;
22

23
    protected function setUp(): void
24
    {
25
        parent::setUp();
×
26

27
        $this->artisan('cache:clear');
×
28

29
        if ((static::$startedTestSuite !== static::class) || !self::$isWrappedIntoTransaction) {
×
30
            $this->artisan('migrate');
×
31

32
            $this->loadTestDump();
×
33

34
            static::$startedTestSuite = static::class;
×
35
        }
36

37
        if (config('database.default') === 'pgsql') {
×
38
            $this->prepareSequences();
×
39
        }
40

41
        Carbon::setTestNow(Carbon::parse($this->testNow));
×
42

43
        Mail::fake();
×
44

45
        $this->beginDatabaseTransaction();
×
46
    }
47

48
    public function tearDown(): void
49
    {
50
        $this->beforeApplicationDestroyed(function () {
×
51
            DB::disconnect();
×
52
        });
×
53

54
        parent::tearDown();
×
55
    }
56

57
    public function callRawRequest(string $method, string $uri, $content, array $headers = []): TestResponse
58
    {
59
        $server = $this->transformHeadersToServerVars($headers);
×
60

61
        return $this->call($method, $uri, [], [], [], $server, $content);
×
62
    }
63

64
    protected function dontWrapIntoTransaction(): void
65
    {
66
        $this->rollbackTransaction();
×
67

68
        self::$isWrappedIntoTransaction = false;
×
69
    }
70

71
    protected function beginDatabaseTransaction(): void
72
    {
73
        $database = $this->app->make('db');
×
74

75
        foreach ($this->connectionsToTransact() as $name) {
×
76
            $connection = $database->connection($name);
×
77
            $dispatcher = $connection->getEventDispatcher();
×
78

79
            $connection->unsetEventDispatcher();
×
80
            $connection->beginTransaction();
×
81
            $connection->setEventDispatcher($dispatcher);
×
82
        }
83

84
        $this->beforeApplicationDestroyed(function () {
×
85
            $this->rollbackTransaction();
×
86
        });
×
87
    }
88

89
    protected function connectionsToTransact(): array
90
    {
91
        return property_exists($this, 'connectionsToTransact') ? $this->connectionsToTransact : [null];
×
92
    }
93

94
    protected function rollbackTransaction(): void
95
    {
96
        $database = $this->app->make('db');
×
97

98
        foreach ($this->connectionsToTransact() as $name) {
×
99
            $connection = $database->connection($name);
×
100
            $dispatcher = $connection->getEventDispatcher();
×
101

102
            $connection->unsetEventDispatcher();
×
103
            $connection->rollback();
×
104
            $connection->setEventDispatcher($dispatcher);
×
105
            $connection->disconnect();
×
106
        }
107
    }
108

109
    protected function prepareModelTestState(string $modelClassName): ModelTestState
110
    {
111
        return (new ModelTestState($modelClassName))->setGlobalExportMode($this->globalExportMode);
2✔
112
    }
113

114
    protected function prepareTableTestState(string $tableName, array $jsonFields = [], ?string $connectionName = null): TableTestState
115
    {
116
        return (new TableTestState($tableName, $jsonFields, $connectionName))->setGlobalExportMode($this->globalExportMode);
2✔
117
    }
118
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc