Skip to content

Commit

Permalink
WIP against Timber v2
Browse files Browse the repository at this point in the history
  • Loading branch information
joelambert committed Oct 25, 2023
1 parent 15eb807 commit eb3c7bb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"psr/http-message": "^1.1",
"psr/http-server-middleware": "^1.0.2",
"blast/facades": "^1.0",
"timber/timber": "^1.23.0",
"timber/timber": "dev-2.x-revert-final-constructors",
"monolog/monolog": "^2.9.1",
"http-interop/response-sender": "^1.0",
"symfony/debug": "^4.4.44",
Expand Down
5 changes: 1 addition & 4 deletions src/Providers/TimberServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ class TimberServiceProvider extends ServiceProvider
{
public function register()
{
$timber = new Timber();

$this->app->bind('timber', $timber);
$this->app->bind(Timber::class, $timber);
Timber::init();
}

public function boot(Config $config)
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/PostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public function can_extend_post_behaviour_with_macros()
public function macros_set_correct_this_context_on_instances()
{
Post::macro('testFunctionAddedByMacro', function () {
return $this->dummyData();
return $this->dummyData;
});

$post = new Post(false, true);
Expand Down
24 changes: 13 additions & 11 deletions tests/Unit/Providers/TimberServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@

namespace Rareloop\Lumberjack\Test\Providers;

use Brain\Monkey;
use Mockery;
use Timber\Timber;
use Brain\Monkey\Functions;
use PHPUnit\Framework\TestCase;
use Rareloop\Lumberjack\Config;
use Rareloop\Lumberjack\Application;
use Rareloop\Lumberjack\Http\Lumberjack;
use Rareloop\Lumberjack\Bootstrappers\BootProviders;
use Rareloop\Lumberjack\Bootstrappers\RegisterProviders;
use Rareloop\Lumberjack\Config;
use Rareloop\Lumberjack\Http\Lumberjack;
use Rareloop\Lumberjack\Providers\TimberServiceProvider;
use Rareloop\Lumberjack\Test\Unit\BrainMonkeyPHPUnitIntegration;
use Timber\Timber;

/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* */
class TimberServiceProviderTest extends TestCase
{
use BrainMonkeyPHPUnitIntegration;
Expand All @@ -22,21 +26,20 @@ class TimberServiceProviderTest extends TestCase
public function timber_plugin_is_initialiased()
{
Functions\expect('is_admin')->once()->andReturn(false);
$timber = Mockery::mock('alias:' . Timber::class);
$timber->shouldReceive('init')->once();

$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');
$lumberjack = new Lumberjack($app);

$app->register(new TimberServiceProvider($app));
$lumberjack->bootstrap();

$this->assertTrue($app->has('timber'));
$this->assertSame($app->get('timber'), $app->get(Timber::class));
}

/** @test */
public function dirname_variable_is_set_from_config()
{
$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');

$config = new Config;
$config->set('timber.paths', [
Expand All @@ -55,11 +58,10 @@ public function dirname_variable_is_set_from_config()

$app->register(new TimberServiceProvider($app));

$this->assertTrue($app->has('timber'));
$this->assertSame([
'path/one',
'path/two',
'path/three',
], $app->get('timber')::$dirname);
], Timber::$dirname);
}
}

0 comments on commit eb3c7bb

Please sign in to comment.