Skip to content

Commit

Permalink
Fixes after merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
distantnative committed Aug 13, 2024
1 parent 9777f08 commit 248c544
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/Cms/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Kirby\Cms\Auth\TotpChallenge;
use Kirby\Form\Field\BlocksField;
use Kirby\Form\Field\LayoutField;
use Kirby\Panel\Ui\FilePreviews\FileImagePreview;
use Kirby\Panel\Ui\FilePreviews\ImageFilePreview;

/**
* The Core class lists all parts of Kirby
Expand Down Expand Up @@ -282,7 +282,7 @@ public function fields(): array
public function filePreviews(): array
{
return [
FileImagePreview::class
ImageFilePreview::class
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
* @since 5.0.0
* @internal
*/
class FileImagePreview extends FilePreview
class ImageFilePreview extends FilePreview
{
public function __construct(
public File $file,
public string $component = 'k-file-image-preview'
public string $component = 'k-image-file-preview'
) {
}

Expand Down
36 changes: 24 additions & 12 deletions tests/Panel/Ui/FilePreviewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ class InvalidFilePreview
*/
class FilePreviewTest extends TestCase
{
public function setUp(): void
{
$this->app = new App([
'roots' => [
'index' => '/dev/null'
],
]);

// authenticate for preview URL
$this->app->impersonate('kirby');
}

/**
* @covers ::details
*/
Expand Down Expand Up @@ -72,8 +84,8 @@ public function testFactory()
$page = new Page(['slug' => 'test']);
$file = new File(['filename' => 'test.pdf', 'parent' => $page]);

$component = FilePreview::factory($file);
$this->assertInstanceOf(DefaultFilePreview::class, $component);
$preview = FilePreview::factory($file);
$this->assertInstanceOf(DefaultFilePreview::class, $preview);
}

/**
Expand All @@ -92,13 +104,13 @@ public function testFactoryWithCustomHandler()

$page = new Page(['slug' => 'test']);

$file = new File(['filename' => 'test.jpg', 'parent' => $page]);
$component = FilePreview::factory($file);
$this->assertInstanceOf(DefaultFilePreview::class, $component);
$file = new File(['filename' => 'test.foo', 'parent' => $page]);
$preview = FilePreview::factory($file);
$this->assertInstanceOf(DefaultFilePreview::class, $preview);

$file = new File(['filename' => 'test.xls', 'parent' => $page]);
$component = FilePreview::factory($file);
$this->assertInstanceOf(DummyFilePreview::class, $component);
$file = new File(['filename' => 'test.xls', 'parent' => $page]);
$preview = FilePreview::factory($file);
$this->assertInstanceOf(DummyFilePreview::class, $preview);
}

/**
Expand Down Expand Up @@ -159,10 +171,10 @@ public function testProps()
*/
public function testRender()
{
$page = new Page(['slug' => 'test']);
$file = new File(['filename' => 'test.jpg', 'parent' => $page]);
$component = new DummyFilePreview($file);
$page = new Page(['slug' => 'test']);
$file = new File(['filename' => 'test.jpg', 'parent' => $page]);
$preview = new DummyFilePreview($file);

$this->assertSame('k-dummy-file-preview', $component->render()['component']);
$this->assertSame('k-dummy-file-preview', $preview->render()['component']);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
use Kirby\TestCase;

/**
* @coversDefaultClass \Kirby\Panel\Ui\FilePreviews\FileImagePreview
* @coversDefaultClass \Kirby\Panel\Ui\FilePreviews\ImageFilePreview
* @covers ::__construct
*/
class FileImagePreviewTest extends TestCase
class ImageFilePreviewTest extends TestCase
{
/**
* @covers ::accepts
Expand All @@ -20,10 +20,10 @@ public function testAccepts()
$page = new Page(['slug' => 'test']);

$file = new File(['filename' => 'test.jpg', 'parent' => $page]);
$this->assertTrue(FileImagePreview::accepts($file));
$this->assertTrue(ImageFilePreview::accepts($file));

$file = new File(['filename' => 'test.xls', 'parent' => $page]);
$this->assertFalse(FileImagePreview::accepts($file));
$this->assertFalse(ImageFilePreview::accepts($file));
}

/**
Expand All @@ -33,7 +33,7 @@ public function testDetails()
{
$page = new Page(['slug' => 'test']);
$file = new File(['filename' => 'test.jpg', 'parent' => $page]);
$preview = new FileImagePreview($file);
$preview = new ImageFilePreview($file);
$details = $preview->details();

$detail = array_pop($details);
Expand All @@ -50,7 +50,7 @@ public function testProps()
{
$page = new Page(['slug' => 'test']);
$file = new File(['filename' => 'test.xls', 'parent' => $page]);
$preview = new FileImagePreview($file);
$preview = new ImageFilePreview($file);
$props = $preview->props();
$this->assertFalse($props['focusable']);
}
Expand Down

0 comments on commit 248c544

Please sign in to comment.