Skip to content

Commit

Permalink
Merge branch 'master' into 2.x-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Sep 8, 2024
2 parents 2d1fca6 + 45deef0 commit 3421778
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
local testsuite=$2
echo "${suite^} tests started"
cd ${suite}_tests
if vendor/bin/pest --colors=always --log-junit="../test_results/${suite}_junit.xml" --testsuite="$testsuite" > "../test_outputs/${suite}.log" 2>&1; then
if vendor/bin/pest --colors=always --compact --log-junit="../test_results/${suite}_junit.xml" --testsuite="$testsuite" > "../test_outputs/${suite}.log" 2>&1; then
echo "${suite^} tests completed successfully"
else
echo "${suite^} tests failed"
Expand Down
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/digging-deeper/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ There are a few ways to create a new `ReadingTime` instance. Either create a new
In all cases, you will end up with a `ReadingTime` object that you can use to get the reading time.

```php
use Hyde\Support\ReadingTime;

// Via constructor
$time = new ReadingTime('Input text string');

Expand Down
2 changes: 1 addition & 1 deletion ide.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{
"methodNames": ["path"],
"place": "parameter",
"classFqn": ["\\Hyde\\Hyde"],
"classFqn": ["Hyde\\Foundation\\HydeKernel", "\\Hyde\\Hyde", "Hyde"],
"parameters": [1]
}
]
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"autoprefixer": "^10.4.20",
"hydefront": "^3.3.0",
"laravel-mix": "^6.0.49",
"postcss": "^8.4.41",
"postcss": "^8.4.45",
"prettier": "3.3.3",
"tailwindcss": "^3.4.10"
}
Expand Down
15 changes: 2 additions & 13 deletions packages/framework/tests/Unit/Facades/RouteFacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
use Hyde\Pages\BladePage;
use Hyde\Pages\MarkdownPage;
use Hyde\Pages\MarkdownPost;
use Hyde\Support\Facades\Render;
use Hyde\Support\Models\RenderData;
use Hyde\Support\Models\Route;
use Hyde\Testing\UnitTestCase;

Expand Down Expand Up @@ -61,20 +59,16 @@ public function testCurrentReturnsCurrentRoute()
{
$route = new Route(new MarkdownPage('foo'));

Render::shouldReceive('getRoute')->andReturn($route);
self::mockRender()->shouldReceive('getRoute')->andReturn($route);

$this->assertSame($route, Routes::current());

$this->resetMockInstance();
}

public function testCurrentReturnsNullIfRouteIsNotFound()
{
Render::shouldReceive('getRoute')->andReturn(null);
self::mockRender()->shouldReceive('getRoute')->andReturn(null);

$this->assertNull(Routes::current());

$this->resetMockInstance();
}

public function testExistsForExistingRoute()
Expand All @@ -86,9 +80,4 @@ public function testExistsForNonExistingRoute()
{
$this->assertFalse(Routes::exists('not-found'));
}

protected function resetMockInstance(): void
{
Render::swap(new RenderData());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
namespace Hyde\Framework\Testing\Unit\Foundation;

use Hyde\Hyde;
use Hyde\Support\Facades\Render;
use Hyde\Support\Models\RenderData;
use Hyde\Testing\InteractsWithPages;
use Hyde\Testing\UnitTestCase;
use Illuminate\Support\Facades\View;
Expand All @@ -22,10 +20,10 @@ class HyperlinkFileHelperRelativeLinkTest extends UnitTestCase

protected static bool $needsKernel = true;
protected static bool $needsConfig = true;
protected static bool $needsRender = true;

protected function setUp(): void
{
Render::swap(new RenderData());
View::swap(Mockery::mock(Factory::class)->makePartial());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ class NavigationItemIsActiveHelperTest extends UnitTestCase
protected static bool $needsKernel = true;
protected static bool $needsConfig = true;

protected function tearDown(): void
{
Render::swap(new RenderData());
}

public function testIsCurrent()
{
$this->mockRenderData($this->makeRoute('foo'));
Expand Down
11 changes: 5 additions & 6 deletions packages/framework/tests/Unit/RouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

use Hyde\Hyde;
use Hyde\Pages\MarkdownPage;
use Hyde\Support\Facades\Render;
use Hyde\Support\Models\RenderData;
use Hyde\Support\Models\Route;
use Hyde\Support\Models\RouteKey;
use Hyde\Testing\UnitTestCase;
Expand All @@ -17,11 +15,12 @@
*/
class RouteTest extends UnitTestCase
{
protected static bool $needsKernel = true;
protected static bool $needsConfig = true;

protected function setUp(): void
{
self::setupKernel();
self::mockConfig();
Render::swap(new RenderData());
self::mockRender();
}

public function testConstructorCreatesRouteFromPageModel()
Expand Down Expand Up @@ -80,7 +79,7 @@ public function testGetLinkReturnsCorrectPathForNestedPages()
public function testGetLinkReturnsCorrectPathForNestedCurrentPage()
{
$route = new Route(new MarkdownPage('foo'));
Render::shouldReceive('getRouteKey')->andReturn('foo/bar');
self::mockCurrentRouteKey('foo/bar');

$this->assertSame(Hyde::relativeLink($route->getOutputPath()), $route->getLink());
$this->assertSame('../foo.html', $route->getLink());
Expand Down
3 changes: 1 addition & 2 deletions packages/hyde/tests/DefaultContentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

declare(strict_types=1);

namespace Hyde\Testing\Hyde;
namespace Hyde\Testing;

use Hyde\Hyde;
use Hyde\Testing\UnitTestCase;

class DefaultContentTest extends UnitTestCase
{
Expand Down
4 changes: 1 addition & 3 deletions packages/hyde/tests/ExampleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

declare(strict_types=1);

namespace Hyde\Testing\Hyde;

use Hyde\Testing\UnitTestCase;
namespace Hyde\Testing;

class ExampleTest extends UnitTestCase
{
Expand Down
4 changes: 1 addition & 3 deletions packages/hyde/tests/HydeCLITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

declare(strict_types=1);

namespace Hyde\Testing\Hyde;

use Hyde\Testing\TestCase;
namespace Hyde\Testing;

class HydeCLITest extends TestCase
{
Expand Down
3 changes: 1 addition & 2 deletions packages/hyde/tests/StaticSiteBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

declare(strict_types=1);

namespace Hyde\Testing\Hyde;
namespace Hyde\Testing;

use Hyde\Hyde;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\File;

class StaticSiteBuilderTest extends TestCase
Expand Down
8 changes: 4 additions & 4 deletions packages/hydefront/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/hydefront/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/hydephp/hydefront#readme",
"devDependencies": {
"sass": "1.77.8"
"sass": "1.78.0"
},
"main": "dist/hyde.css"
}
4 changes: 1 addition & 3 deletions packages/testing/src/Common/BaseHydePageUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Illuminate\View\Factory;
use Hyde\Testing\UnitTestCase;
use Hyde\Support\Facades\Render;
use Hyde\Support\Models\RenderData;
use Illuminate\Support\Facades\View;
use Hyde\Testing\CreatesTemporaryFiles;

Expand All @@ -27,6 +26,7 @@ protected function setUp(): void
{
self::setupKernel();
self::mockConfig();
self::mockRender();

View::swap($mock = Mockery::mock(Factory::class, [
'make' => Mockery::mock(Factory::class, [
Expand All @@ -39,8 +39,6 @@ protected function setUp(): void
]));
app()->bind(\Illuminate\Contracts\View\Factory::class, fn () => $mock);
app()->bind('view', fn () => $mock);

Render::swap(new RenderData());
}

protected function tearDown(): void
Expand Down
19 changes: 19 additions & 0 deletions packages/testing/src/UnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
namespace Hyde\Testing;

use Hyde\Foundation\HydeKernel;
use Hyde\Support\Facades\Render;
use Illuminate\Config\Repository;
use Hyde\Support\Models\RenderData;
use Illuminate\Support\Facades\Config;
use PHPUnit\Framework\TestCase as BaseTestCase;

Expand All @@ -15,6 +17,7 @@ abstract class UnitTestCase extends BaseTestCase

protected static bool $needsKernel = false;
protected static bool $needsConfig = false;
protected static bool $needsRender = false;

protected static function needsKernel(): void
{
Expand All @@ -32,6 +35,10 @@ public static function setUpBeforeClass(): void
if (static::$needsConfig) {
self::mockConfig();
}

if (static::$needsRender) {
self::mockRender();
}
}

protected static function setupKernel(): void
Expand All @@ -45,6 +52,18 @@ protected static function resetKernel(): void
HydeKernel::setInstance(new HydeKernel());
}

protected static function mockRender(): Render
{
Render::swap(new RenderData());

return new Render();
}

protected static function mockCurrentRouteKey(?string $routeKey = null): void
{
self::mockRender()->shouldReceive('getRouteKey')->andReturn($routeKey);
}

protected static function mockConfig(array $items = []): void
{
app()->bind('config', fn (): Repository => new Repository($items));
Expand Down

0 comments on commit 3421778

Please sign in to comment.