Skip to content

Commit

Permalink
Statamic 5 Support (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
martink635 authored May 22, 2024
1 parent 642ec10 commit 71fce38
Show file tree
Hide file tree
Showing 37 changed files with 472 additions and 231 deletions.
1 change: 1 addition & 0 deletions .phpunit.cache/test-results
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":1,"defects":{"Cnj\\Seotamic\\Tests\\SitemapTest::test_it_returns_a_working_sitemap":8,"Cnj\\Seotamic\\Tests\\SitemapTest::test_it_returns_404_when_sitemap_is_disabled":7,"Cnj\\Seotamic\\Tests\\MetaTest::test_it_returns_a_working_sitemap":8,"Cnj\\Seotamic\\Tests\\MetaTest::test_seotamic_title_is_returned_correctly":7,"Cnj\\Seotamic\\Tests\\MetaTest::test_seotamic_custom_title_is_returned_correctly":8,"Cnj\\Seotamic\\Tests\\MetaTest::test_meta_has_all_the_expected_keys":8,"Cnj\\Seotamic\\Tests\\SocialTest::test_meta_has_all_the_expected_keys":8},"times":{"Cnj\\Seotamic\\Tests\\ExampleTest::test_that_true_is_true":0.006,"Cnj\\Seotamic\\Tests\\SitemapTest::test_it_returns_404_when_sitemap_is_disabled":0.01,"Cnj\\Seotamic\\Tests\\SitemapTest::test_it_returns_a_working_sitemap":0.011,"Cnj\\Seotamic\\Tests\\BaseTest::test_that_true_is_true":0.003,"Cnj\\Seotamic\\Tests\\MetaTest::test_it_returns_a_working_sitemap":0.038,"Cnj\\Seotamic\\Tests\\MetaTest::test_meta_has_all_the_expected_keys":0.022,"Cnj\\Seotamic\\Tests\\MetaTest::test_seotamic_title_is_returned_correctly":0.011,"Cnj\\Seotamic\\Tests\\MetaTest::test_seotamic_custom_title_is_returned_correctly":0.036,"Cnj\\Seotamic\\Tests\\SocialTest::test_meta_has_all_the_expected_keys":0.013}}
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
"type": "statamic-addon",
"license": "proprietary",
"require": {
"php": "^8.1",
"statamic/cms": "^4.0.0"
"php": "^8.2",
"statamic/cms": "^5.0.0"
},
"require-dev": {
"orchestra/testbench": "^7.0",
"phpunit/phpunit": "^9.5.10"
"orchestra/testbench": "^9.0"
},
"autoload-dev": {
"psr-4": {
Expand Down
21 changes: 21 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.1/phpunit.xsd" processIsolation="false" stopOnFailure="false" beStrictAboutTestsThatDoNotTestAnything="false" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_KEY" value="base64:ybcI9MKuhLnESRSuWDfnJQuohOXMBaynfbTC5Y5i1FE="/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
<env name="MAIL_MAILER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="TELESCOPE_ENABLED" value="false"/>
</php>
<source/>
</phpunit>
24 changes: 0 additions & 24 deletions phpunit.xml.dist

This file was deleted.

11 changes: 11 additions & 0 deletions tests/BaseTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Cnj\Seotamic\Tests;

class BaseTest extends TestCase
{
public function test_that_true_is_true(): void
{
$this->assertTrue(true);
}
}
56 changes: 0 additions & 56 deletions tests/ExceptionHandler.php

This file was deleted.

19 changes: 19 additions & 0 deletions tests/MetaTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Cnj\Seotamic\Tests;

use Statamic\Facades\Entry;

class MetaTest extends TestCase
{
public function test_meta_has_all_the_expected_keys(): void
{
$entry = Entry::find('home');

$this->assertArrayHasKey('title', $entry->seotamic_meta);
$this->assertArrayHasKey('description', $entry->seotamic_meta);
$this->assertArrayHasKey('canonical', $entry->seotamic_meta);
$this->assertArrayHasKey('robots', $entry->seotamic_meta);
$this->assertArrayHasKey('related', $entry->seotamic_meta);
}
}
17 changes: 17 additions & 0 deletions tests/SitemapTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Cnj\Seotamic\Tests;

use Statamic\Facades\Config;

class SitemapTest extends TestCase
{
public function test_it_returns_404_when_sitemap_is_disabled(): void
{
Config::set('seotamic.sitemap', false);

$this
->get('/sitemap.xml')
->assertStatus(404);
}
}
20 changes: 20 additions & 0 deletions tests/SocialTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Cnj\Seotamic\Tests;

use Statamic\Facades\Entry;

class SocialTest extends TestCase
{
public function test_meta_has_all_the_expected_keys(): void
{
$entry = Entry::find('home');

$this->assertArrayHasKey('open_graph', $entry->seotamic_social);
$this->assertArrayHasKey('twitter', $entry->seotamic_social);
$this->assertArrayHasKey('site_name', $entry->seotamic_social);
$this->assertArrayHasKey('title', $entry->seotamic_social);
$this->assertArrayHasKey('description', $entry->seotamic_social);
$this->assertArrayHasKey('image', $entry->seotamic_social);
}
}
38 changes: 8 additions & 30 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,19 @@

namespace Cnj\Seotamic\Tests;

use Orchestra\Testbench\TestCase as OrchestraTestCase;
use Cnj\Seotamic\ServiceProvider;
use Statamic\Testing\AddonTestCase;
use Statamic\Facades\YAML;
use Statamic\Facades\Site;

class TestCase extends OrchestraTestCase
abstract class TestCase extends AddonTestCase
{
protected string $addonServiceProvider = ServiceProvider::class;

protected function setUp(): void
{
require_once(__DIR__.'/ExceptionHandler.php');

parent::setUp();
}

protected function getPackageProviders($app)
{
return [
\Statamic\Providers\StatamicServiceProvider::class,
\Cnj\Seotamic\ServiceProvider::class,
];
}

protected function getPackageAliases($app)
{
return [
'Statamic' => Statamic::class,
];
}

protected function getEnvironmentSetUp($app)
{
parent::getEnvironmentSetUp($app);

$app->make(\Statamic\Extend\Manifest::class)->manifest = [
'cnj/seotamic' => [
'id' => 'cnj/seotamic',
'namespace' => 'Cnj\\Seotamic\\',
],
];
Site::setSites(YAML::file(__DIR__ . "/__fixtures__/sites.yaml")->parse());
}
}
52 changes: 0 additions & 52 deletions tests/Unit/DescriptionTest.php

This file was deleted.

65 changes: 0 additions & 65 deletions tests/Unit/TitleTest.php

This file was deleted.

Empty file.
2 changes: 2 additions & 0 deletions tests/__fixtures__/content/assets/assets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: Assets
disk: assets
Empty file.
18 changes: 18 additions & 0 deletions tests/__fixtures__/content/collections/pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
title: Pages
sites:
- en
- it
- sl
propagate: false
template: default
layout: layout
revisions: false
route: '{parent_uri}/{slug}'
sort_dir: asc
preview_targets:
-
label: Entry
url: '{permalink}'
refresh: true
structure:
root: true
Loading

0 comments on commit 71fce38

Please sign in to comment.