use BookStack\Facades\Theme;
use BookStack\Theming\ThemeEvents;
use League\CommonMark\Block\Element\ListItem;
-use League\CommonMark\CommonMarkConverter;
use League\CommonMark\Environment;
use League\CommonMark\Extension\Table\TableExtension;
use League\CommonMark\Extension\TaskList\TaskListExtension;
+use League\CommonMark\MarkdownConverter;
class MarkdownToHtml
{
$environment->addExtension(new TaskListExtension());
$environment->addExtension(new CustomStrikeThroughExtension());
$environment = Theme::dispatch(ThemeEvents::COMMONMARK_ENVIRONMENT_CONFIGURE, $environment) ?? $environment;
- $converter = new CommonMarkConverter([], $environment);
+ $converter = new MarkdownConverter($environment);
$environment->addBlockRenderer(ListItem::class, new CustomListItemRenderer(), 10);
*
* @returns array<string, int>
*/
- protected function generateTermScoreMapFromText(string $text, int $scoreAdjustment = 1): array
+ protected function generateTermScoreMapFromText(string $text, float $scoreAdjustment = 1): array
{
$termMap = $this->textToTermCountMap($text);
foreach ($termMap as $term => $count) {
- $termMap[$term] = $count * $scoreAdjustment;
+ $termMap[$term] = floor($count * $scoreAdjustment);
}
return $termMap;
protected function getAllowedIframeHosts(): array
{
- $hosts = config('app.iframe_hosts', '');
+ $hosts = config('app.iframe_hosts') ?? '';
return array_filter(explode(' ', $hosts));
}
public function definition()
{
return [
- 'name' => $this->faker->city,
+ 'name' => $this->faker->city(),
'value' => $this->faker->sentence(3),
];
}
{
return [
'name' => 'My webhook for ' . $this->faker->country(),
- 'endpoint' => $this->faker->url,
+ 'endpoint' => $this->faker->url(),
'active' => true,
'timeout' => 3,
];
*/
public function definition()
{
- $name = $this->faker->name;
+ $name = $this->faker->name();
return [
'name' => $name,
- 'email' => $this->faker->email,
+ 'email' => $this->faker->email(),
'slug' => Str::slug($name . '-' . Str::random(5)),
'password' => Str::random(10),
'remember_token' => Str::random(10),
public function definition()
{
return [
- 'name' => $this->faker->sentence,
+ 'name' => $this->faker->sentence(),
'slug' => Str::random(10),
- 'description' => $this->faker->paragraph,
+ 'description' => $this->faker->paragraph(),
];
}
}
public function definition()
{
return [
- 'name' => $this->faker->sentence,
+ 'name' => $this->faker->sentence(),
'slug' => Str::random(10),
- 'description' => $this->faker->paragraph,
+ 'description' => $this->faker->paragraph(),
];
}
}
$html = '<p>' . implode('</p>', $this->faker->paragraphs(5)) . '</p>';
return [
- 'name' => $this->faker->sentence,
+ 'name' => $this->faker->sentence(),
'slug' => Str::random(10),
'html' => $html,
'text' => strip_tags($html),
public function definition()
{
return [
- 'name' => $this->faker->slug . '.jpg',
- 'url' => $this->faker->url,
- 'path' => $this->faker->url,
+ 'name' => $this->faker->slug() . '.jpg',
+ 'url' => $this->faker->url(),
+ 'path' => $this->faker->url(),
'type' => 'gallery',
'uploaded_to' => 0,
];
Once done you can run `composer test` in the application root directory to run all tests. Tests can be ran in parallel by running them via `composer t`. This will use Laravel's built-in parallel testing functionality, and attempt to create and seed a database instance for each testing thread. If required these parallel testing instances can be reset, before testing again, by running `composer t-reset`.
+If the codebase needs to be tested with deprecations, this can be done via uncommenting the relevant line within the TestCase@setUp function.
+
## Code Standards
PHP code standards are managed by [using PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer).
style="display: none;"
class="notification pos"
role="alert">
- @icon('check-circle') <span>{!! nl2br(htmlentities(session()->get('success'))) !!}</span><div class="dismiss">@icon('close')</div>
+ @icon('check-circle') <span>@if(session()->has('success')){!! nl2br(htmlentities(session()->get('success'))) !!}@endif</span><div class="dismiss">@icon('close')</div>
</div>
<div component="notification"
style="display: none;"
class="notification warning"
role="alert">
- @icon('info') <span>{!! nl2br(htmlentities(session()->get('warning'))) !!}</span><div class="dismiss">@icon('close')</div>
+ @icon('info') <span>@if(session()->has('warning')){!! nl2br(htmlentities(session()->get('warning'))) !!}@endif</span><div class="dismiss">@icon('close')</div>
</div>
<div component="notification"
style="display: none;"
class="notification neg"
role="alert">
- @icon('danger') <span>{!! nl2br(htmlentities(session()->get('error'))) !!}</span><div class="dismiss">@icon('close')</div>
+ @icon('danger') <span>@if(session()->has('error')){!! nl2br(htmlentities(session()->get('error'))) !!}@endif</span><div class="dismiss">@icon('close')</div>
</div>
\ No newline at end of file
@endif
@icon('star'){!! trans('entities.meta_created' . ($entity->createdBy ? '_name' : ''), [
- 'timeLength' => $entity->created_at->formatLocalized('%e %B %Y %H:%M:%S'),
+ 'timeLength' => $entity->created_at->isoFormat('D MMMM Y HH:mm:ss'),
'user' => e($entity->createdBy->name ?? ''),
]) !!}
<br>
@icon('edit'){!! trans('entities.meta_updated' . ($entity->updatedBy ? '_name' : ''), [
- 'timeLength' => $entity->updated_at->formatLocalized('%e %B %Y %H:%M:%S'),
+ 'timeLength' => $entity->updated_at->isoFormat('D MMMM Y HH:mm:ss'),
'user' => e($entity->updatedBy->name ?? '')
]) !!}
</div>
\ No newline at end of file
@if($revision->createdBy) {{ $revision->createdBy->name }} @else {{ trans('common.deleted_user') }} @endif
<br>
<div class="text-muted">
- <small>{{ $revision->created_at->formatLocalized('%e %B %Y %H:%M:%S') }}</small>
+ <small>{{ $revision->created_at->isoFormat('D MMMM Y HH:mm:ss') }}</small>
<small>({{ $revision->created_at->diffForHumans() }})</small>
</div>
</div>
$page = $this->entities->page();
$resp = $this->asEditor()->get($page->getUrl('/export/html'));
- $resp->assertSee($page->created_at->formatLocalized('%e %B %Y %H:%M:%S'));
+ $resp->assertSee($page->created_at->isoFormat('D MMMM Y HH:mm:ss'));
$resp->assertDontSee($page->created_at->diffForHumans());
- $resp->assertSee($page->updated_at->formatLocalized('%e %B %Y %H:%M:%S'));
+ $resp->assertSee($page->updated_at->isoFormat('D MMMM Y HH:mm:ss'));
$resp->assertDontSee($page->updated_at->diffForHumans());
}
{
$this->asEditor();
$page = $this->entities->page();
- config()->push('app.allow_content_scripts', 'true');
+ config()->set('app.allow_content_scripts', 'true');
$script = 'abc123<script>console.log("hello-test")</script>abc123';
$page->html = "no escape {$script}";
{
$this->asEditor();
$page = $this->entities->page();
- config()->push('app.allow_content_scripts', 'true');
+ config()->set('app.allow_content_scripts', 'true');
$script = '<p onmouseenter="console.log(\'test\')">Hello</p>';
$page->html = "escape {$script}";
{
$this->entities = new EntityProvider();
parent::setUp();
+
+ // We can uncomment the below to run tests with failings upon deprecations.
+ // Can't leave on since some deprecations can only be fixed upstream.
+ // $this->withoutDeprecationHandling();
}
/**