Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['8.1', '8.2', '8.3']
php-versions: ['8.1', '8.4']

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
strategy:
matrix:
php-versions: ['8.1', '8.2', '8.3']
php-versions: ['8.1', '8.2', '8.3', '8.4']

steps:
- name: Free Disk Space (Ubuntu)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['8.1', '8.2', '8.3']
php-versions: ['8.1', '8.4']

steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"require": {
"php": "^8.1",
"mnapoli/front-yaml": "^2.0",
"myth/collection": "dev-master"
"myth/collection": "dev-develop"
},
"require-dev": {
"codeigniter4/devkit": "^1.0",
"codeigniter4/devkit": "^1.3",
"codeigniter4/framework": "^4.1"
},
"minimum-stability": "dev",
Expand Down
31 changes: 31 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
parameters:
ignoreErrors:
-
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Michalsn\\\\CodeIgniterMarkdownPages\\\\MarkdownPages'' and Michalsn\\CodeIgniterMarkdownPages\\MarkdownPages will always evaluate to true\.$#'
identifier: method.alreadyNarrowedType
count: 1
path: tests/MarkdownPagesTest.php

-
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Michalsn\\\\CodeIgniterMarkdownPages\\\\Pages\\\\Content'' and Michalsn\\CodeIgniterMarkdownPages\\Pages\\Content will always evaluate to true\.$#'
identifier: method.alreadyNarrowedType
count: 3
path: tests/MarkdownPagesTest.php

-
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Michalsn\\\\CodeIgniterMarkdownPages\\\\Pages\\\\File'' and Michalsn\\CodeIgniterMarkdownPages\\Pages\\File will always evaluate to true\.$#'
identifier: method.alreadyNarrowedType
count: 1
path: tests/MarkdownPagesTest.php

-
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Michalsn\\\\CodeIgniterMarkdownPages\\\\Search\\\\Results'' and Michalsn\\CodeIgniterMarkdownPages\\Search\\Results will always evaluate to true\.$#'
identifier: method.alreadyNarrowedType
count: 3
path: tests/MarkdownPagesTest.php

-
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Myth\\\\Collection\\\\Collection'' and Myth\\Collection\\Collection will always evaluate to true\.$#'
identifier: method.alreadyNarrowedType
count: 17
path: tests/MarkdownPagesTest.php
2 changes: 2 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
includes:
- phpstan-baseline.neon
parameters:
tmpDir: build/phpstan
level: 5
Expand Down
94 changes: 33 additions & 61 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,32 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="vendor/codeigniter4/framework/system/Test/bootstrap.php"
backupGlobals="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
executionOrder="random"
failOnRisky="true"
failOnWarning="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="true">

<coverage includeUncoveredFiles="true" processUncoveredFiles="true">
<include>
<directory suffix=".php">./src/</directory>
</include>
<exclude>
<directory suffix=".php">./src/Commands</directory>
<directory suffix=".php">./src/Config</directory>
</exclude>
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/codeigniter4/framework/system/Test/bootstrap.php"
backupGlobals="false"
beStrictAboutOutputDuringTests="true"
colors="true"
executionOrder="random"
failOnRisky="true"
failOnWarning="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
cacheDirectory="build/.phpunit.cache"
beStrictAboutCoverageMetadata="true">
<coverage includeUncoveredFiles="true">
<report>
<clover outputFile="build/phpunit/clover.xml"/>
<html outputDirectory="build/phpunit/html"/>
Expand All @@ -35,68 +23,52 @@
<xml outputDirectory="build/phpunit/xml-coverage"/>
</report>
</coverage>

<testsuites>
<testsuite name="main">
<directory>./tests</directory>
</testsuite>
</testsuites>

<extensions>
<extension class="Nexus\PHPUnit\Extension\Tachycardia">
<arguments>
<array>
<element key="timeLimit">
<double>0.50</double>
</element>
<element key="reportable">
<integer>30</integer>
</element>
<element key="precision">
<integer>2</integer>
</element>
<element key="collectBare">
<boolean>true</boolean>
</element>
<element key="tabulate">
<boolean>true</boolean>
</element>
</array>
</arguments>
</extension>
<bootstrap class="Nexus\PHPUnit\Tachycardia\TachycardiaExtension">
<parameter name="time-limit" value="0.50"/>
<parameter name="report-count" value="30"/>
<parameter name="format" value="table"/>
</bootstrap>
</extensions>

<logging>
<testdoxHtml outputFile="build/phpunit/testdox.html"/>
<testdoxText outputFile="build/phpunit/testdox.txt"/>
<junit outputFile="build/phpunit/junit.xml"/>
</logging>

<php>
<env name="XDEBUG_MODE" value="coverage"/>
<server name="app.baseURL" value="https://example.com/"/>

<!-- Directory containing phpunit.xml -->
<const name="HOMEPATH" value="./"/>

<!-- Directory containing the Paths config file -->
<const name="CONFIGPATH" value="vendor/codeigniter4/framework/app/Config/"/>

<!-- Directory containing the front controller (index.php) -->
<const name="PUBLICPATH" value="./public/"/>

<!-- https://getcomposer.org/xdebug -->
<env name="COMPOSER_DISABLE_XDEBUG_WARN" value="1"/>

<!-- Database configuration -->
<env name="database.tests.strictOn" value="true"/>
<!-- Uncomment to use alternate testing database configuration
<env name="database.tests.hostname" value="localhost"/>
<env name="database.tests.database" value="tests"/>
<env name="database.tests.username" value="tests_user"/>
<env name="database.tests.hostname" value="127.0.0.1"/>
<env name="database.tests.port" value="3306"/>
<env name="database.tests.database" value="nested_model"/>
<env name="database.tests.username" value="root"/>
<env name="database.tests.password" value=""/>
<env name="database.tests.DBDriver" value="MySQLi"/>
<env name="database.tests.DBPrefix" value="tests_"/>
<env name="database.tests.DBPrefix" value="db_"/>
-->
</php>
<source>
<include>
<directory suffix=".php">./src/</directory>
</include>
<exclude>
<directory suffix=".php">./src/Config</directory>
</exclude>
</source>
</phpunit>
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
cacheDirectory="build/psalm/"
findUnusedBaselineEntry="true"
findUnusedCode="false"
ensureOverrideAttribute="false"
>
<projectFiles>
<directory name="src/" />
Expand Down
2 changes: 0 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
use Rector\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector;
use Rector\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
use Rector\ValueObject\PhpVersion;
Expand Down Expand Up @@ -138,7 +137,6 @@
$rectorConfig->rule(StringClassNameToClassConstantRector::class);
$rectorConfig->rule(PrivatizeFinalClassPropertyRector::class);
$rectorConfig->rule(CompleteDynamicPropertiesRector::class);
$rectorConfig->rule(BooleanInIfConditionRuleFixerRector::class);
$rectorConfig->rule(SingleInArrayToCompareRector::class);
$rectorConfig->rule(VersionCompareFuncCallToConstantRector::class);
$rectorConfig->rule(ExplicitBoolCompareRector::class);
Expand Down
4 changes: 2 additions & 2 deletions src/MarkdownPages.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ public function __construct(string $folderPath, protected MarkdownPagesConfig $c
// Parser
$parser = new Parser(
$config->yamlParser !== null ? new $config->yamlParser() : null,
$config->markdownParser !== null ? new $config->markdownParser() : null
$config->markdownParser !== null ? new $config->markdownParser() : null,
);

// Prepare folders and files
$this->pages = new Collection([]);

$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($folderPath, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST
RecursiveIteratorIterator::SELF_FIRST,
);

foreach ($iterator as $file) {
Expand Down
6 changes: 3 additions & 3 deletions src/Pages/Dir.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(
protected string $dirName,
protected string $basePath,
protected string $fileExtension,
protected Parser $parser
protected Parser $parser,
) {
helper('inflector');

Expand Down Expand Up @@ -74,7 +74,7 @@ private function init(): void
$this->dirName,
$this->basePath,
$this->depth,
$this->parser
$this->parser,
));
}
}
Expand Down Expand Up @@ -189,6 +189,6 @@ private function cleanup(string $name): string
*/
private function cleanupArray(array $paths): array
{
return array_map(fn ($path) => $this->cleanup($path), $paths);
return array_map($this->cleanup(...), $paths);
}
}
6 changes: 3 additions & 3 deletions src/Pages/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(
protected string $dirName,
protected string $basePath,
protected int $depth,
protected Parser $parser
protected Parser $parser,
) {
helper('inflector');

Expand All @@ -27,7 +27,7 @@ public function __construct(
$this->name = humanize($this->slug, '-');

$paths = explode('/', $dirName);
$this->dirNamePath = implode('/', array_map(fn ($path) => $this->cleanup($path), $paths));
$this->dirNamePath = implode('/', array_map($this->cleanup(...), $paths));
$this->path = implode('/', [$this->dirNamePath, $this->slug]);
}

Expand Down Expand Up @@ -96,7 +96,7 @@ public function load(bool $throw = false): ?string
DIRECTORY_SEPARATOR,
[
$this->basePath, $this->getDirName(), $this->getFileName(),
]
],
);

if (! file_exists($path)) {
Expand Down
7 changes: 5 additions & 2 deletions tests/MarkdownPagesTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests;

use CodeIgniter\Test\ReflectionHelper;
Expand Down Expand Up @@ -69,7 +71,7 @@ public function testDirDoesNotExist()
$markdownPages = new MarkdownPages($this->folderPath, $this->config);
$dir = $markdownPages->dir('incorrect');

$this->assertNull($dir);
$this->assertNotInstanceOf(Dir::class, $dir);
}

public function testDirWithArray()
Expand Down Expand Up @@ -347,6 +349,7 @@ public function testFileLoadException()
$file = $markdownPages->file('folder/file-1');

$this->setPrivateProperty($file, 'fileName', 'error');
$this->assertInstanceOf(File::class, $file);
$file->load(true);
}

Expand All @@ -355,7 +358,7 @@ public function testFileDoesNotExist()
$markdownPages = new MarkdownPages($this->folderPath, $this->config);
$file = $markdownPages->file('folder/file-11111');

$this->assertNull($file);
$this->assertNotInstanceOf(File::class, $file);
}

public function testFileWithHtmlExtension()
Expand Down
2 changes: 2 additions & 0 deletions tests/_support/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Support;

use CodeIgniter\Test\CIUnitTestCase;
Expand Down