1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-06 13:16:45 +02:00

feat(core): use FLEXTYPE_ prefix for all core constants

This commit is contained in:
Awilum
2022-07-04 21:41:20 +03:00
parent fb05dbd70a
commit 572e35e835
29 changed files with 79 additions and 79 deletions

View File

@@ -23,12 +23,12 @@ define('FLEXTYPE_START_TIME', microtime(true));
/**
* Define the PATH to the root directory (without trailing slash).
*/
define('ROOT_DIR', str_replace(DIRECTORY_SEPARATOR, '/', getcwd()));
define('FLEXTYPE_ROOT_DIR', str_replace(DIRECTORY_SEPARATOR, '/', getcwd()));
/**
* Ensure vendor libraries exist
*/
! is_file($flextypeAutoload = ROOT_DIR . '/vendor/autoload.php') and exit('Please run: <i>composer install</i> for flextype');
! is_file($flextypeAutoload = FLEXTYPE_ROOT_DIR . '/vendor/autoload.php') and exit('Please run: <i>composer install</i> for flextype');
/**
* Register The Auto Loader
@@ -49,4 +49,4 @@ $flextypeLoader = require_once $flextypeAutoload;
* the responses back to the browser and delight our users.
*/
require_once ROOT_DIR . '/src/flextype/flextype.php';
require_once FLEXTYPE_ROOT_DIR . '/src/flextype/flextype.php';

View File

@@ -29,7 +29,7 @@ define('FLEXTYPE_START_TIME', microtime(true));
/**
* Define the PATH to the root directory (without trailing slash).
*/
define('ROOT_DIR', str_replace(DIRECTORY_SEPARATOR, '/', getcwd()));
define('FLEXTYPE_ROOT_DIR', str_replace(DIRECTORY_SEPARATOR, '/', getcwd()));
/**
* Ensure vendor libraries exist

View File

@@ -52,7 +52,7 @@ class AboutCommand extends Command
hr('[b]Constants[/b]', 'my-1') .
div('[b][color=success]FLEXTYPE_PROJECT_NAME[/color][/b]: ' . FLEXTYPE_PROJECT_NAME, '') .
div('[b][color=success]ROOT_DIR[/color][/b]: ' . ROOT_DIR, '') .
div('[b][color=success]FLEXTYPE_ROOT_DIR[/color][/b]: ' . FLEXTYPE_ROOT_DIR, '') .
div('[b][color=success]FLEXTYPE_PATH_PROJECT[/color][/b]: ' . FLEXTYPE_PATH_PROJECT, '') .
div('[b][color=success]FLEXTYPE_PATH_TMP[/color][/b]: ' . FLEXTYPE_PATH_TMP, '') .
div('[b][color=success]FLEXTYPE_MINIMUM_PHP[/color][/b]: ' . FLEXTYPE_MINIMUM_PHP, '') .

View File

@@ -124,8 +124,8 @@ class Entries
continue;
}
if (filesystem()->file(ROOT_DIR . '/' . $value['path'])->exists()) {
include_once ROOT_DIR . '/' . $value['path'];
if (filesystem()->file(FLEXTYPE_ROOT_DIR . '/' . $value['path'])->exists()) {
include_once FLEXTYPE_ROOT_DIR . '/' . $value['path'];
}
}
}
@@ -140,8 +140,8 @@ class Entries
public function initDirectives(array $directives): void
{
foreach ($directives as $key => $value) {
if (filesystem()->file(ROOT_DIR . '/' . $value['path'])->exists()) {
include_once ROOT_DIR . '/' . $value['path'];
if (filesystem()->file(FLEXTYPE_ROOT_DIR . '/' . $value['path'])->exists()) {
include_once FLEXTYPE_ROOT_DIR . '/' . $value['path'];
}
}
}
@@ -208,7 +208,7 @@ class Entries
continue;
}
$events[] = ROOT_DIR . '/' . $event['path'];
$events[] = FLEXTYPE_ROOT_DIR . '/' . $event['path'];
}
}
@@ -249,7 +249,7 @@ class Entries
continue;
}
$fields[] = ROOT_DIR . '/' . $field['path'];
$fields[] = FLEXTYPE_ROOT_DIR . '/' . $field['path'];
}
}

View File

@@ -25,7 +25,7 @@ emitter()->addListener('onEntriesFetchSingleHasResult', static function (): void
}
// Determine is the current field file path is the same.
if (! strings(__FILE__)->replace(ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.fetch.collection.fields.created_at.path'))) {
if (! strings(__FILE__)->replace(FLEXTYPE_ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.fetch.collection.fields.created_at.path'))) {
return;
}
@@ -44,7 +44,7 @@ emitter()->addListener('onEntriesCreate', static function (): void {
}
// Determine is the current field file path is the same.
if (! strings(__FILE__)->replace(ROOT_DIR, '')->isEqual(entries()->registry()->get('methods.create.collection.fields.created_at.path'))) {
if (! strings(__FILE__)->replace(FLEXTYPE_ROOT_DIR, '')->isEqual(entries()->registry()->get('methods.create.collection.fields.created_at.path'))) {
return;
}

View File

@@ -24,7 +24,7 @@ emitter()->addListener('onEntriesCreate', static function (): void {
}
// Determine is the current field file path is the same.
if (! strings(__FILE__)->replace(ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.create.collection.fields.created_by.path'))) {
if (! strings(__FILE__)->replace(FLEXTYPE_ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.create.collection.fields.created_by.path'))) {
return;
}

View File

@@ -24,7 +24,7 @@ emitter()->addListener('onEntriesFetchSingleHasResult', static function (): void
}
// Determine is the current field file path is the same.
if (! strings(__FILE__)->replace(ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.fetch.collection.fields.id.path'))) {
if (! strings(__FILE__)->replace(FLEXTYPE_ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.fetch.collection.fields.id.path'))) {
return;
}

View File

@@ -25,7 +25,7 @@ emitter()->addListener('onEntriesFetchSingleHasResult', static function (): void
}
// Determine is the current field file path is the same.
if (! strings(__FILE__)->replace(ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.fetch.collection.fields.modified_at.path'))) {
if (! strings(__FILE__)->replace(FLEXTYPE_ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.fetch.collection.fields.modified_at.path'))) {
return;
}

View File

@@ -25,7 +25,7 @@ emitter()->addListener('onEntriesFetchSingleHasResult', static function (): void
}
// Determine is the current field file path is the same.
if (! strings(__FILE__)->replace(ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.fetch.collection.fields.published_at.path'))) {
if (! strings(__FILE__)->replace(FLEXTYPE_ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.fetch.collection.fields.published_at.path'))) {
return;
}
@@ -44,7 +44,7 @@ emitter()->addListener('onEntriesCreate', static function (): void {
}
// Determine is the current field file path is the same.
if (! strings(__FILE__)->replace(ROOT_DIR, '')->isEqual(entries()->registry()->get('methods.create.collection.fields.published_at.path'))) {
if (! strings(__FILE__)->replace(FLEXTYPE_ROOT_DIR, '')->isEqual(entries()->registry()->get('methods.create.collection.fields.published_at.path'))) {
return;
}

View File

@@ -24,7 +24,7 @@ emitter()->addListener('onEntriesCreate', static function (): void {
}
// Determine is the current field file path is the same.
if (! strings(__FILE__)->replace(ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.create.collection.fields.published_by.path'))) {
if (! strings(__FILE__)->replace(FLEXTYPE_ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.create.collection.fields.published_by.path'))) {
return;
}

View File

@@ -24,7 +24,7 @@ emitter()->addListener('onEntriesFetchSingleHasResult', static function (): void
}
// Determine is the current field file path is the same.
if (! strings(__FILE__)->replace(ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.fetch.collection.fields.routable.path'))) {
if (! strings(__FILE__)->replace(FLEXTYPE_ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.fetch.collection.fields.routable.path'))) {
return;
}
@@ -44,7 +44,7 @@ emitter()->addListener('onEntriesCreate', static function (): void {
}
// Determine is the current field file path is the same.
if (! strings(__FILE__)->replace(ROOT_DIR, '')->isEqual(entries()->registry()->get('methods.create.collection.fields.routable.path'))) {
if (! strings(__FILE__)->replace(FLEXTYPE_ROOT_DIR, '')->isEqual(entries()->registry()->get('methods.create.collection.fields.routable.path'))) {
return;
}

View File

@@ -24,7 +24,7 @@ emitter()->addListener('onEntriesFetchSingleHasResult', static function (): void
}
// Determine is the current field file path is the same.
if (! strings(__FILE__)->replace(ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.fetch.collection.fields.slug.path'))) {
if (! strings(__FILE__)->replace(FLEXTYPE_ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.fetch.collection.fields.slug.path'))) {
return;
}

View File

@@ -25,7 +25,7 @@ emitter()->addListener('onEntriesCreate', static function (): void {
}
// Determine is the current field file path is the same.
if (! strings(__FILE__)->replace(ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.create.collection.fields.uuid.path'))) {
if (! strings(__FILE__)->replace(FLEXTYPE_ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.create.collection.fields.uuid.path'))) {
return;
}

View File

@@ -24,7 +24,7 @@ emitter()->addListener('onEntriesFetchSingleHasResult', static function (): void
}
// Determine is the current field file path is the same.
if (! strings(__FILE__)->replace(ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.fetch.collection.fields.visibility.path'))) {
if (! strings(__FILE__)->replace(FLEXTYPE_ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.fetch.collection.fields.visibility.path'))) {
return;
}
@@ -49,7 +49,7 @@ emitter()->addListener('onEntriesCreate', static function (): void {
}
// Determine is the current field file path is the same.
if (! strings(__FILE__)->replace(ROOT_DIR, '')->isEqual(entries()->registry()->get('methods.create.collection.fields.visibility.path'))) {
if (! strings(__FILE__)->replace(FLEXTYPE_ROOT_DIR, '')->isEqual(entries()->registry()->get('methods.create.collection.fields.visibility.path'))) {
return;
}

View File

@@ -24,7 +24,7 @@ emitter()->addListener('onEntriesCreate', static function (): void {
}
// Determine is the current field file path is the same.
if (! strings(__FILE__)->replace(ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.create.collection.fields.calls.path'))) {
if (! strings(__FILE__)->replace(FLEXTYPE_ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.create.collection.fields.calls.path'))) {
return;
}

View File

@@ -24,7 +24,7 @@ emitter()->addListener('onEntriesFetchSingleHasResult', static function (): void
}
// Determine is the current field file path is the same.
if (! strings(__FILE__)->replace(ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.fetch.collection.fields.id.path'))) {
if (! strings(__FILE__)->replace(FLEXTYPE_ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.fetch.collection.fields.id.path'))) {
return;
}

View File

@@ -24,7 +24,7 @@ emitter()->addListener('onEntriesCreate', static function (): void {
}
// Determine is the current field file path is the same.
if (! strings(__FILE__)->replace(ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.create.collection.fields.limit_calls.path'))) {
if (! strings(__FILE__)->replace(FLEXTYPE_ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.create.collection.fields.limit_calls.path'))) {
return;
}

View File

@@ -24,7 +24,7 @@ emitter()->addListener('onEntriesCreate', static function (): void {
}
// Determine is the current field file path is the same.
if (! strings(__FILE__)->replace(ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.create.collection.fields.state.path'))) {
if (! strings(__FILE__)->replace(FLEXTYPE_ROOT_DIR, '')->replaceFirst('/', '')->isEqual(entries()->registry()->get('methods.create.collection.fields.state.path'))) {
return;
}

View File

@@ -117,11 +117,11 @@ final class Shortcodes
continue;
}
if (! file_exists(ROOT_DIR . '/' . $shortcode['path'])) {
if (! file_exists(FLEXTYPE_ROOT_DIR . '/' . $shortcode['path'])) {
continue;
}
include_once ROOT_DIR . '/' . $shortcode['path'];
include_once FLEXTYPE_ROOT_DIR . '/' . $shortcode['path'];
}
}

View File

@@ -50,7 +50,7 @@ class Plugins
*/
public function __construct()
{
$this->locales = serializers()->yaml()->decode(filesystem()->file(ROOT_DIR . '/src/flextype/locales.yaml')->get());
$this->locales = serializers()->yaml()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/src/flextype/locales.yaml')->get());
$this->init();
}

View File

@@ -34,12 +34,12 @@ if (! defined('FLEXTYPE_PATH_PROJECT')) {
/**
* Define the project path (without trailing slash).
*/
define('FLEXTYPE_PATH_PROJECT', ROOT_DIR . '/' . FLEXTYPE_PROJECT_NAME);
define('FLEXTYPE_PATH_PROJECT', FLEXTYPE_ROOT_DIR . '/' . FLEXTYPE_PROJECT_NAME);
}
if (! defined('FLEXTYPE_PATH_TMP')) {
/**
* Define the project tmp path (without trailing slash).
*/
define('FLEXTYPE_PATH_TMP', ROOT_DIR . '/var/tmp');
define('FLEXTYPE_PATH_TMP', FLEXTYPE_ROOT_DIR . '/var/tmp');
}

View File

@@ -85,7 +85,7 @@ use const DIRECTORY_SEPARATOR;
use const PHP_VERSION;
// Get defines.
require_once ROOT_DIR . '/src/flextype/defines.php';
require_once FLEXTYPE_ROOT_DIR . '/src/flextype/defines.php';
// Check PHP Version
version_compare($ver = PHP_VERSION, $req = FLEXTYPE_MINIMUM_PHP, '<') and exit(sprintf('You are running PHP %s, but Flextype needs at least <strong>PHP %s</strong> to run.', $ver, $req));
@@ -104,8 +104,8 @@ container()->set('registry', registry());
container()->set('actions', Actions::getInstance());
// Init Flextype config (manifest and settings)
$flextypeManifestFilePath = ROOT_DIR . '/src/flextype/flextype.yaml';
$defaultFlextypeSettingsFilePath = ROOT_DIR . '/src/flextype/settings.yaml';
$flextypeManifestFilePath = FLEXTYPE_ROOT_DIR . '/src/flextype/flextype.yaml';
$defaultFlextypeSettingsFilePath = FLEXTYPE_ROOT_DIR . '/src/flextype/settings.yaml';
$customFlextypeSettingsFilePath = FLEXTYPE_PATH_PROJECT . '/config/flextype/settings.yaml';
$preflightFlextypePath = FLEXTYPE_PATH_TMP . '/config/flextype/';
$customFlextypeSettingsPath = FLEXTYPE_PATH_PROJECT . '/config/flextype/';
@@ -359,16 +359,16 @@ View::setDirectory(FLEXTYPE_PATH_PROJECT);
View::setExtension(registry()->get('flextype.settings.view.extension'));
// Add bootstrap file before plugins intialization.
require_once ROOT_DIR . '/src/flextype/bootstrap/before-plugins.php';
require_once FLEXTYPE_ROOT_DIR . '/src/flextype/bootstrap/before-plugins.php';
// Add Plugins Service
container()->set('plugins', new Plugins());
// Add bootstrap file before plugins intialization.
require_once ROOT_DIR . '/src/flextype/bootstrap/after-plugins.php';
require_once FLEXTYPE_ROOT_DIR . '/src/flextype/bootstrap/after-plugins.php';
// Add Routes file.
require_once ROOT_DIR . '/src/flextype/routes/routes.php';
require_once FLEXTYPE_ROOT_DIR . '/src/flextype/routes/routes.php';
// Enable lazy CORS
//

View File

@@ -6,7 +6,7 @@ namespace Flextype;
use function Glowy\Filesystem\filesystem;
define('ROOT_DIR', str_replace(DIRECTORY_SEPARATOR, '/', getcwd()));
define('FLEXTYPE_ROOT_DIR', str_replace(DIRECTORY_SEPARATOR, '/', getcwd()));
/**
* Define the project name.
@@ -16,15 +16,15 @@ define('FLEXTYPE_PROJECT_NAME', 'project');
/**
* Define the PATH (without trailing slash).
*/
define('FLEXTYPE_PATH_PROJECT', ROOT_DIR . '/' . FLEXTYPE_PROJECT_NAME);
define('FLEXTYPE_PATH_TMP', ROOT_DIR . '/var/tmp');
define('FLEXTYPE_PATH_PROJECT', FLEXTYPE_ROOT_DIR . '/' . FLEXTYPE_PROJECT_NAME);
define('FLEXTYPE_PATH_TMP', FLEXTYPE_ROOT_DIR . '/var/tmp');
! is_file($flextype_autoload = ROOT_DIR . '/vendor/autoload.php') and exit('Please run: <i>composer install</i> for flextype');
! is_file($flextype_autoload = FLEXTYPE_ROOT_DIR . '/vendor/autoload.php') and exit('Please run: <i>composer install</i> for flextype');
$flextype_loader = require_once $flextype_autoload;
filesystem()->directory(FLEXTYPE_PATH_TMP)->exists() and filesystem()->directory(FLEXTYPE_PATH_TMP)->delete();
filesystem()->directory(ROOT_DIR . '/project/config/flextype/')->ensureExists(0755, true);
filesystem()->file(ROOT_DIR . '/tests/fixtures/settings/settings.yaml')->copy(ROOT_DIR . '/project/config/flextype/settings.yaml');
filesystem()->directory(FLEXTYPE_ROOT_DIR . '/project/config/flextype/')->ensureExists(0755, true);
filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/settings/settings.yaml')->copy(FLEXTYPE_ROOT_DIR . '/project/config/flextype/settings.yaml');
include ROOT_DIR . '/src/flextype/flextype.php';
include FLEXTYPE_ROOT_DIR . '/src/flextype/flextype.php';

View File

@@ -13,9 +13,9 @@ afterEach(function (): void {
});
test('EntriesMacros for blog', function () {
entries()->create('blog', serializers()->yaml()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/blog/blog.yaml')->get()));
entries()->create('blog/post-1', serializers()->frontmatter()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/blog/post-1/post.md')->get()));
entries()->create('blog/post-2', serializers()->frontmatter()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/blog/post-2/post.md')->get()));
entries()->create('blog', serializers()->yaml()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/blog/blog.yaml')->get()));
entries()->create('blog/post-1', serializers()->frontmatter()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/blog/post-1/post.md')->get()));
entries()->create('blog/post-2', serializers()->frontmatter()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/blog/post-2/post.md')->get()));
$blog = entries()->fetch('blog');
$posts = entries()->fetch('blog', ['collection' => true]);
@@ -26,8 +26,8 @@ test('EntriesMacros for blog', function () {
test('EntriesMacros for shop', function() {
filesystem()
->directory(ROOT_DIR . '/tests/fixtures/entries/shop')
->copy(ROOT_DIR . '/project/entries/shop');
->directory(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/shop')
->copy(FLEXTYPE_ROOT_DIR . '/project/entries/shop');
$shop = entries()->fetch('shop');
@@ -40,10 +40,10 @@ test('EntriesMacros for shop', function() {
test('EntriesMacros for catalog', function () {
// Create catalog
entries()->create('catalog', serializers()->yaml()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/catalog/entry.yaml')->get()));
entries()->create('catalog/bikes', serializers()->yaml()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/catalog/bikes/entry.yaml')->get()));
entries()->create('catalog/bikes/gt', serializers()->yaml()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/catalog/bikes/gt/entry.yaml')->get()));
entries()->create('catalog/bikes/norco', serializers()->yaml()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/catalog/bikes/norco/entry.yaml')->get()));
entries()->create('catalog', serializers()->yaml()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/catalog/entry.yaml')->get()));
entries()->create('catalog/bikes', serializers()->yaml()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/catalog/bikes/entry.yaml')->get()));
entries()->create('catalog/bikes/gt', serializers()->yaml()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/catalog/bikes/gt/entry.yaml')->get()));
entries()->create('catalog/bikes/norco', serializers()->yaml()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/catalog/bikes/norco/entry.yaml')->get()));
entries()->create('catalog/bikes/foo', ['title' => 'foo']);
entries()->create('catalog/bikes/foo/bar', ['title' => 'bar']);
@@ -81,11 +81,11 @@ test('EntriesMacros for catalog', function () {
});
test('EntriesMacros for albmus', function () {
entries()->create('root', serializers()->yaml()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/root/entry.yaml')->get()));
entries()->create('root', serializers()->yaml()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/root/entry.yaml')->get()));
entries()->create('albums', serializers()->yaml()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/root/albums/entry.yaml')->get()));
entries()->create('albums/category-1', serializers()->yaml()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/root/albums/category-1/entry.yaml')->get()));
entries()->create('albums/category-1/album-1', serializers()->yaml()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/root/albums/category-1/album-1/entry.yaml')->get()));
entries()->create('albums', serializers()->yaml()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/root/albums/entry.yaml')->get()));
entries()->create('albums/category-1', serializers()->yaml()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/root/albums/category-1/entry.yaml')->get()));
entries()->create('albums/category-1/album-1', serializers()->yaml()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/root/albums/category-1/album-1/entry.yaml')->get()));
entries()->create('banners', ['title' => 'Banners']);
entries()->create('banners/1', ['title' => 'Banner1']);
@@ -97,10 +97,10 @@ test('EntriesMacros for albmus', function () {
});
test('EntriesMacros for long nested entries', function () {
entries()->create('level1', serializers()->yaml()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/level1/entry.yaml')->get()));
entries()->create('level1/level2', serializers()->yaml()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/level1/level2/entry.yaml')->get()));
entries()->create('level1/level2/level3', serializers()->yaml()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/level1/level2/level3/entry.yaml')->get()));
entries()->create('level1/level2/level3/level4', serializers()->yaml()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/level1/level2/level3/level4/entry.yaml')->get()));
entries()->create('level1', serializers()->yaml()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/level1/entry.yaml')->get()));
entries()->create('level1/level2', serializers()->yaml()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/level1/level2/entry.yaml')->get()));
entries()->create('level1/level2/level3', serializers()->yaml()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/level1/level2/level3/entry.yaml')->get()));
entries()->create('level1/level2/level3/level4', serializers()->yaml()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/level1/level2/level3/level4/entry.yaml')->get()));
$level = entries()->fetch('level1');

View File

@@ -13,7 +13,7 @@ afterEach(function (): void {
});
test('PhpMacros', function () {
entries()->create('blog', serializers()->yaml()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/blog-php-macros/entry.yaml')->get()));
entries()->create('blog', serializers()->yaml()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/blog-php-macros/entry.yaml')->get()));
$this->assertTrue(entries()->create('blog/post-1', ['title' => 'Post 1']));
$this->assertTrue(entries()->create('blog/post-2', ['title' => 'Post 2']));
$this->assertTrue(entries()->create('blog/post-3', ['title' => 'Post 3']));

View File

@@ -13,9 +13,9 @@ afterEach(function (): void {
});
test('RegistryMacros', function () {
entries()->create('registry-root', serializers()->yaml()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/registry-root/entry.yaml')->get()));
entries()->create('registry-root/level-1', serializers()->yaml()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/registry-root/level-1/entry.yaml')->get()));
entries()->create('registry-root/level-1/level-2', serializers()->yaml()->decode(filesystem()->file(ROOT_DIR . '/tests/fixtures/entries/registry-root/level-1/level-2/entry.yaml')->get()));
entries()->create('registry-root', serializers()->yaml()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/registry-root/entry.yaml')->get()));
entries()->create('registry-root/level-1', serializers()->yaml()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/registry-root/level-1/entry.yaml')->get()));
entries()->create('registry-root/level-1/level-2', serializers()->yaml()->decode(filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/entries/registry-root/level-1/level-2/entry.yaml')->get()));
$data = entries()->fetch('registry-root');

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
use function Glowy\Filesystem\filesystem;
test('encode', function () {
$string = filesystem()->file(ROOT_DIR . '/tests/fixtures/serializers/frontmatter.md')->get();
$string = filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/serializers/frontmatter.md')->get();
$this->assertEquals($string,
serializers()->frontmatter()
->encode(['title' => 'Foo',
@@ -17,31 +17,31 @@ test('decode', function () {
$this->assertEquals(['title' => 'Foo',
'content' => 'Content is here.'],
serializers()->frontmatter()
->decode($string = filesystem()->file(ROOT_DIR . '/tests/fixtures/serializers/frontmatter.md')->get()));
->decode($string = filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/serializers/frontmatter.md')->get()));
$this->assertEquals(['title' => 'Frontmatter YAML',
'content' => 'Content is here.'],
serializers()->frontmatter()
->decode($string = filesystem()->file(ROOT_DIR . '/tests/fixtures/serializers/frontmatter-yaml.md')->get()));
->decode($string = filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/serializers/frontmatter-yaml.md')->get()));
$this->assertEquals(['title' => 'Frontmatter JSON',
'content' => 'Content is here.'],
serializers()->frontmatter()
->decode($string = filesystem()->file(ROOT_DIR . '/tests/fixtures/serializers/frontmatter-json.md')->get()));
->decode($string = filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/serializers/frontmatter-json.md')->get()));
$this->assertEquals(['title' => 'Frontmatter JSON5',
'content' => 'Content is here.'],
serializers()->frontmatter()
->decode($string = filesystem()->file(ROOT_DIR . '/tests/fixtures/serializers/frontmatter-json5.md')->get()));
->decode($string = filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/serializers/frontmatter-json5.md')->get()));
$this->assertEquals(['title' => 'Frontmatter NEON',
'content' => 'Content is here.'],
serializers()->frontmatter()
->decode($string = filesystem()->file(ROOT_DIR . '/tests/fixtures/serializers/frontmatter-neon.md')->get()));
->decode($string = filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/serializers/frontmatter-neon.md')->get()));
});
test('get cache ID', function () {
$string = filesystem()->file(ROOT_DIR . '/tests/fixtures/serializers/frontmatter.md')->get();;
$string = filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/serializers/frontmatter.md')->get();;
$cache_id = serializers()->frontmatter()
->getCacheID($string);
$this->assertEquals(32, strlen($cache_id));

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
use function Glowy\Filesystem\filesystem;
test('encode', function () {
$string = filesystem()->file(ROOT_DIR . '/tests/fixtures/serializers/neon.neon')->get();
$string = filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/serializers/neon.neon')->get();
$this->assertEquals(trim("{" . $string . "}"),
trim(serializers()->neon()->encode(['hello' => 'world'])));
});
@@ -13,11 +13,11 @@ test('encode', function () {
test('decode', function () {
$this->assertEquals(['hello' => 'world'],
serializers()->neon()
->decode($string = filesystem()->file(ROOT_DIR . '/tests/fixtures/serializers/neon.neon')->get()));
->decode($string = filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/serializers/neon.neon')->get()));
});
test('get cache ID', function () {
$string = filesystem()->file(ROOT_DIR . '/tests/fixtures/serializers/neon.neon')->get();;
$string = filesystem()->file(FLEXTYPE_ROOT_DIR . '/tests/fixtures/serializers/neon.neon')->get();;
$cache_id = serializers()->neon()
->getCacheID($string);
$this->assertEquals(32, strlen($cache_id));

View File

@@ -12,7 +12,7 @@ test('encode', function () {
});
test('decode', function () {
$this->assertEquals(['title' => 'Foo', 'content' => 'Bar'], serializers()->phparray()->decode(ROOT_DIR . '/tests/fixtures/serializers/phparray.php'));
$this->assertEquals(['title' => 'Foo', 'content' => 'Bar'], serializers()->phparray()->decode(FLEXTYPE_ROOT_DIR . '/tests/fixtures/serializers/phparray.php'));
});
test('get cache ID', function () {