use BookStack\Actions\DispatchWebhookJob;
use BookStack\Actions\Webhook;
use BookStack\Auth\User;
+use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Page;
use BookStack\Entities\Tools\PageContent;
use BookStack\Facades\Theme;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Http;
-use Illuminate\Support\Str;
use League\CommonMark\ConfigurableEnvironmentInterface;
class ThemeTest extends TestCase
file_put_contents($translationPath . '/entities.php', $customTranslations);
$homeRequest = $this->actingAs($this->getViewer())->get('/');
- $homeRequest->assertElementContains('header nav', 'Sandwiches');
+ $this->withHtml($homeRequest)->assertElementContains('header nav', 'Sandwiches');
});
}
});
}
+ public function test_event_activity_logged()
+ {
+ $book = Book::query()->first();
+ $args = [];
+ $callback = function (...$eventArgs) use (&$args) {
+ $args = $eventArgs;
+ };
+
+ Theme::listen(ThemeEvents::ACTIVITY_LOGGED, $callback);
+ $this->asEditor()->put($book->getUrl(), ['name' => 'My cool update book!']);
+
+ $this->assertCount(2, $args);
+ $this->assertEquals(ActivityType::BOOK_UPDATE, $args[0]);
+ $this->assertTrue($args[1] instanceof Book);
+ $this->assertEquals($book->id, $args[1]->id);
+ }
+
public function test_add_social_driver()
{
Theme::addSocialDriver('catnet', [
$bodyStartStr = 'barry-fought-against-the-panther';
$bodyEndStr = 'barry-lost-his-fight-with-grace';
- $this->usingThemeFolder(function(string $folder) use ($bodyStartStr, $bodyEndStr) {
+ $this->usingThemeFolder(function (string $folder) use ($bodyStartStr, $bodyEndStr) {
$viewDir = theme_path('layouts/parts');
mkdir($viewDir, 0777, true);
file_put_contents($viewDir . '/base-body-start.blade.php', $bodyStartStr);
File::makeDirectory($themeFolderPath);
// Run provided callback with theme env option set
- $this->runWithEnv('APP_THEME', $themeFolderName, function() use ($callback, $themeFolderName) {
+ $this->runWithEnv('APP_THEME', $themeFolderName, function () use ($callback, $themeFolderName) {
call_user_func($callback, $themeFolderName);
});