Skip to content

Commit 985b078

Browse files
committed
add tests
1 parent f0e3611 commit 985b078

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

tests/Feature/Entries/EntryRevisionsTest.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,66 @@ public function it_denies_access_to_revisions_without_permission_to_view_entry()
140140
->assertForbidden();
141141
}
142142

143+
#[Test]
144+
public function it_denies_access_to_a_specific_revision_without_permission_to_view_entry()
145+
{
146+
$this->setTestBlueprint('test', ['foo' => ['type' => 'text']]);
147+
$this->setTestRoles(['test' => ['access cp']]);
148+
$user = User::make()->id('user-1')->assignRole('test')->save();
149+
150+
$entry = EntryFactory::id('1')
151+
->slug('test')
152+
->collection('blog')
153+
->published(true)
154+
->date('2010-12-25')
155+
->data([
156+
'blueprint' => 'test',
157+
'title' => 'Original title',
158+
'foo' => 'bar',
159+
])->create();
160+
161+
$revision = tap($entry->makeRevision(), function ($copy) {
162+
$copy->message('Revision one');
163+
$copy->date(Carbon::parse('2017-02-01'));
164+
});
165+
$revision->save();
166+
167+
$this
168+
->actingAs($user)
169+
->get($entry->revisionsUrl().'/'.$revision->date()->timestamp)
170+
->assertForbidden();
171+
}
172+
173+
#[Test]
174+
public function it_denies_creating_a_revision_without_permission_to_edit_entry()
175+
{
176+
$this->setTestBlueprint('test', ['foo' => ['type' => 'text']]);
177+
$this->setTestRoles(['test' => ['access cp', 'view blog entries']]);
178+
$user = User::make()->id('user-1')->assignRole('test')->save();
179+
180+
$entry = EntryFactory::id('1')
181+
->slug('test')
182+
->collection('blog')
183+
->published(false)
184+
->date('2010-12-25')
185+
->data([
186+
'blueprint' => 'test',
187+
'title' => 'Title',
188+
'foo' => 'bar',
189+
])->create();
190+
191+
tap($entry->makeWorkingCopy(), function ($copy) {
192+
$attrs = $copy->attributes();
193+
$attrs['data']['foo'] = 'foo modified in working copy';
194+
$copy->attributes($attrs);
195+
})->save();
196+
197+
$this
198+
->actingAs($user)
199+
->post($entry->createRevisionUrl(), ['message' => 'Test!'])
200+
->assertForbidden();
201+
}
202+
143203
#[Test]
144204
public function it_publishes_an_entry()
145205
{

0 commit comments

Comments
 (0)