-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConfigurationTest.php
More file actions
75 lines (57 loc) · 1.97 KB
/
Copy pathConfigurationTest.php
File metadata and controls
75 lines (57 loc) · 1.97 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
namespace TestMonitor\Revisable\Tests;
use PHPUnit\Framework\Attributes\Test;
use TestMonitor\Revisable\Exceptions\InvalidConfiguration;
use TestMonitor\Revisable\Models\Revision;
use TestMonitor\Revisable\RevisableServiceProvider;
use TestMonitor\Revisable\Tests\Models\Author;
class ConfigurationTest extends TestCase
{
// Revision model
#[Test]
public function it_returns_the_default_revision_model_class()
{
// When
$revisionModel = RevisableServiceProvider::determineRevisionModel();
// Then
$this->assertEquals(Revision::class, $revisionModel);
}
#[Test]
public function it_throws_when_the_configured_revision_model_does_not_extend_the_base_revision()
{
// Given
config()->set('revisable.revision_model', \stdClass::class);
// When / Then
$this->expectException(InvalidConfiguration::class);
RevisableServiceProvider::determineRevisionModel();
}
#[Test]
public function it_throws_when_the_configured_revision_model_class_does_not_exist()
{
// Given
config()->set('revisable.revision_model', 'App\\Models\\NonExistentRevision');
// When / Then
$this->expectException(InvalidConfiguration::class);
RevisableServiceProvider::determineRevisionModel();
}
// User model
#[Test]
public function it_returns_the_configured_user_model_class()
{
// Given
config()->set('revisable.user_model', Author::class);
// When
$userModel = RevisableServiceProvider::determineUserModel();
// Then
$this->assertEquals(Author::class, $userModel);
}
#[Test]
public function it_throws_when_the_user_model_is_not_a_valid_model_class()
{
// Given
config()->set('revisable.user_model', \stdClass::class);
// When / Then
$this->expectException(InvalidConfiguration::class);
RevisableServiceProvider::determineUserModel();
}
}