Skip to content

Commit b64654e

Browse files
authored
Ensure global variables save (#442)
1 parent d7bfc91 commit b64654e

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

src/Globals/Variables.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ protected function getOriginByString($origin)
4949
return $this->globalSet()->in($origin);
5050
}
5151

52-
public function save()
53-
{
54-
$this->toModel()->save();
55-
56-
return $this;
57-
}
58-
5952
public function model($model = null)
6053
{
6154
if (func_num_args() === 0) {

tests/Globals/GlobalsetTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Globals;
4+
5+
use Illuminate\Support\Facades\Event;
6+
use PHPUnit\Framework\Attributes\Test;
7+
use Statamic\Events\GlobalSetSaved;
8+
use Statamic\Events\GlobalVariablesSaved;
9+
use Statamic\Facades;
10+
use Tests\TestCase;
11+
12+
class GlobalsetTest extends TestCase
13+
{
14+
#[Test]
15+
public function fires_events_when_globalset_saved()
16+
{
17+
Event::fake();
18+
19+
$global = Facades\Globalset::make('test');
20+
21+
$global->addLocalization(
22+
$global->makeLocalization('en')->data(['foo' => 'bar', 'baz' => 'qux'])
23+
);
24+
25+
$global->save();
26+
27+
Event::assertDispatched(GlobalSetSaved::class);
28+
Event::assertDispatched(GlobalVariablesSaved::class);
29+
}
30+
}

0 commit comments

Comments
 (0)