Skip to content

Commit

Permalink
Support Statamic v4 (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseleite authored May 3, 2023
1 parent df48578 commit 7e4a76a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 27 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ jobs:

strategy:
matrix:
php: [7.4, 8.0, 8.1]
laravel: [8.*, 9.*]
php: [8.0, 8.1, 8.2]
laravel: [9.*, 10.*]
stability: [prefer-lowest, prefer-stable]
os: [ubuntu-latest]
include:
- os: windows-latest
php: 7.4
laravel: 8.*
php: 8.1
laravel: 9.*
stability: prefer-stable
- os: windows-latest
php: 8.1
laravel: 9.*
laravel: 10.*
stability: prefer-stable
exclude:
- laravel: 9.*
php: 7.4
- php: 8.0
laravel: 10.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
}
},
"require": {
"statamic/cms": "~3.3.0 || ~3.4.0"
"statamic/cms": "^4.0"
},
"require-dev": {
"orchestra/testbench": "^5.20.0 || ^6.22.0 || ^7.0"
"orchestra/testbench": "^7.0 || ^8.0",
"phpunit/phpunit": "^9.0"
},
"config": {
"allow-plugins": {
Expand Down
4 changes: 2 additions & 2 deletions src/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function addSeoFields()

static::$addingField = true;

$this->blueprint->ensureFieldInSection('seo', ['type' => 'seo_pro', 'listable' => false, 'display' => 'SEO'], 'SEO');
$this->blueprint->ensureFieldInTab('seo', ['type' => 'seo_pro', 'listable' => false, 'display' => 'SEO'], 'SEO');

static::$addingField = false;
}
Expand All @@ -71,7 +71,7 @@ public function addSeoFields()
*/
public function removeSeoFields()
{
$this->blueprint->removeSection('SEO');
$this->blueprint->removeTab('SEO');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/CascadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function it_generates_compiled_title_from_cascaded_parts()
/** @test */
public function it_parses_field_references()
{
$entry = Entry::findBySlug('about', 'pages');
$entry = Entry::findByUri('/about')->entry();

$entry->data(['favourite_colour' => 'Red'])->save();

Expand Down
24 changes: 12 additions & 12 deletions tests/MetaTagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function it_doesnt_generate_meta_when_seo_is_disabled_on_entry($viewType)
{
$this
->prepareViews($viewType)
->setSeoOnEntry(Entry::findBySlug('about', 'pages'), false);
->setSeoOnEntry(Entry::findByUri('/about'), false);

$response = $this->get('/about');
$response->assertSee("<h1>{$viewType}</h1>", false);
Expand Down Expand Up @@ -165,7 +165,7 @@ public function it_uses_cascade_to_generate_meta($viewType)
'title' => 'Aboot',
'site_name_separator' => '>',
])
->setSeoOnEntry(Entry::findBySlug('about', 'pages'), [
->setSeoOnEntry(Entry::findByUri('/about'), [
'site_name_position' => 'before',
'site_name_separator' => '--',
]);
Expand All @@ -183,7 +183,7 @@ public function it_generates_sanitized_title($viewType)
{
$this
->prepareViews($viewType)
->setSeoOnEntry(Entry::findBySlug('about', 'pages'), [
->setSeoOnEntry(Entry::findByUri('/about'), [
'title' => " It's a me, <b>Mario</b>! ",
'site_name' => ' Cool "Runnings" ',
'site_name_position' => 'before',
Expand All @@ -204,7 +204,7 @@ public function it_generates_sanitized_description($viewType)
{
$this
->prepareViews($viewType)
->setSeoOnEntry(Entry::findBySlug('about', 'pages'), [
->setSeoOnEntry(Entry::findByUri('/about'), [
'description' => " It's a me, <b>Mario</b>! ",
]);

Expand Down Expand Up @@ -240,7 +240,7 @@ public function it_generates_twitter_handle_meta($viewType)
->setSeoInSiteDefaults([
'twitter_handle' => ' itsmario85 ',
])
->setSeoOnEntry(Entry::findBySlug('about', 'pages'), [
->setSeoOnEntry(Entry::findByUri('/about'), [
'twitter_handle' => '@itsluigi85',
]);

Expand All @@ -263,7 +263,7 @@ public function it_generates_social_image($viewType)

$this
->prepareViews($viewType)
->setSeoOnEntry(Entry::findBySlug('about', 'pages'), [
->setSeoOnEntry(Entry::findByUri('/about'), [
'image' => 'img/stetson.jpg',
]);

Expand All @@ -286,7 +286,7 @@ public function it_generates_social_image_with_custom_glide_presets($viewType)

$this
->prepareViews($viewType)
->setSeoOnEntry(Entry::findBySlug('about', 'pages'), [
->setSeoOnEntry(Entry::findByUri('/about'), [
'image' => 'img/stetson.jpg',
]);

Expand All @@ -308,7 +308,7 @@ public function it_generates_social_image_with_og_glide_preset_only($viewType)

$this
->prepareViews($viewType)
->setSeoOnEntry(Entry::findBySlug('about', 'pages'), [
->setSeoOnEntry(Entry::findByUri('/about'), [
'image' => 'img/stetson.jpg',
]);

Expand All @@ -331,7 +331,7 @@ public function it_generates_social_image_with_twitter_glide_preset_only($viewTy

$this
->prepareViews($viewType)
->setSeoOnEntry(Entry::findBySlug('about', 'pages'), [
->setSeoOnEntry(Entry::findByUri('/about'), [
'image' => 'img/stetson.jpg',
]);

Expand Down Expand Up @@ -488,7 +488,7 @@ public function it_generates_canonical_url_meta_with_custom_url($viewType)
{
$this
->prepareViews($viewType)
->setSeoOnEntry(Entry::findBySlug('about', 'pages'), [
->setSeoOnEntry(Entry::findByUri('/about'), [
'canonical_url' => 'https://hot-walkings.com/pages/aboot',
]);

Expand All @@ -505,7 +505,7 @@ public function it_applies_pagination_to_custom_canonical_url_on_same_domain($vi
{
$this
->prepareViews($viewType)
->setSeoOnEntry(Entry::findBySlug('about', 'pages'), [
->setSeoOnEntry(Entry::findByUri('/about'), [
'canonical_url' => 'http://cool-runnings.com/pages/aboot',
]);

Expand All @@ -522,7 +522,7 @@ public function it_doesnt_apply_pagination_to_external_custom_canonical_url($vie
{
$this
->prepareViews($viewType)
->setSeoOnEntry(Entry::findBySlug('about', 'pages'), [
->setSeoOnEntry(Entry::findByUri('/about'), [
'canonical_url' => 'https://hot-walkings.com/pages/aboot',
]);

Expand Down
4 changes: 2 additions & 2 deletions tests/SitemapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function it_uses_cascade_to_generate_priorities()
->setSeoOnCollection(Collection::find('pages'), [
'priority' => 0.2,
])
->setSeoOnEntry(Entry::findBySlug('about', 'pages'), [
->setSeoOnEntry(Entry::findByUri('/about')->entry(), [
'priority' => 0.3,
]);

Expand All @@ -172,7 +172,7 @@ public function it_uses_cascade_to_generate_frequencies()
->setSeoOnCollection(Collection::find('pages'), [
'change_frequency' => 'daily',
])
->setSeoOnEntry(Entry::findBySlug('about', 'pages'), [
->setSeoOnEntry(Entry::findByUri('/about')->entry(), [
'change_frequency' => 'hourly',
]);

Expand Down
2 changes: 1 addition & 1 deletion tests/ViewScenarios.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

trait ViewScenarios
{
public function viewScenarioProvider()
public static function viewScenarioProvider()
{
return [
['antlers'],
Expand Down

0 comments on commit 7e4a76a

Please sign in to comment.