-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMigrateLocalizedGlobalSetTest.php
69 lines (55 loc) · 2.19 KB
/
MigrateLocalizedGlobalSetTest.php
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
<?php
namespace Tests;
class MigrateLocalizedGlobalSetTest extends TestCase
{
protected $siteFixture = 'site-localized';
protected function paths($key = null)
{
$paths = [
'set' => base_path('content/globals/global.yaml'),
'default' => base_path('content/globals/default/global.yaml'),
'fr' => base_path('content/globals/fr/global.yaml'),
];
return $key ? $paths[$key] : $paths;
}
/** @test */
public function it_can_migrate_a_global_set()
{
$this->artisan('statamic:migrate:global-set', ['handle' => 'global']);
$expectedSet = [
'title' => 'Main Globals',
];
$expectedEnglish = [
'site_name' => 'Redwood',
'company' => 'Baller Inc',
'author_name' => 'Niles Peppertrout',
'fav_tag' => 'coffee', // this is a taxonomy field, with a value that needs to be migrated
];
$expectedFrench = [
'origin' => 'default',
'site_name' => 'La Redwoody',
'fav_tag' => 'spring', // this is a taxonomy field, with a value that needs to be migrated
];
$this->assertParsedYamlEquals($expectedSet, $this->paths('set'));
$this->assertParsedYamlEquals($expectedEnglish, $this->paths('default'));
$this->assertParsedYamlEquals($expectedFrench, $this->paths('fr'));
}
/** @test */
public function it_can_migrate_when_localized_data_does_not_exist()
{
$this->files->deleteDirectory($this->sitePath('content/globals/fr'));
$this->artisan('statamic:migrate:global-set', ['handle' => 'global']);
$expectedSet = [
'title' => 'Main Globals',
];
$expectedEnglish = [
'site_name' => 'Redwood',
'company' => 'Baller Inc',
'author_name' => 'Niles Peppertrout',
'fav_tag' => 'coffee', // this is a taxonomy field, with a value that needs to be migrated
];
$this->assertParsedYamlEquals($expectedSet, $this->paths('set'));
$this->assertParsedYamlEquals($expectedEnglish, $this->paths('default'));
$this->assertFileNotExists($this->paths('fr'));
}
}