Skip to content

Commit

Permalink
Fix tests (#9)
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
dereuromark committed Nov 14, 2023
1 parent aa8a094 commit 79938d5
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 56 deletions.
1 change: 1 addition & 0 deletions src/Model/Table/FileStorageTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Cake\Core\Configure;
use Cake\Database\Schema\TableSchemaInterface;
use Cake\ORM\Table;
use FileStorage\Database\Type\ArrayType;

/**
* FileStorageTable
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase/FileStorageTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Cake\ORM\Locator\LocatorAwareTrait;
use Cake\TestSuite\TestCase;
use FileStorage\Filesystem\Folder;
use FileStorage\Model\Table\FileStorageTable;
use Intervention\Image\ImageManager;
use PhpCollective\Infrastructure\Storage\Factories\LocalFactory;
use PhpCollective\Infrastructure\Storage\FileStorage;
Expand Down Expand Up @@ -80,7 +81,7 @@ public function setUp(): void

$this->FileStorage = $this
->getTableLocator()
->get(FileStorageTestTable::class);
->get(FileStorageTable::class);
}

/**
Expand Down
47 changes: 0 additions & 47 deletions tests/TestCase/FileStorageTestTable.php

This file was deleted.

4 changes: 2 additions & 2 deletions tests/TestCase/Model/Behavior/FileStorageBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use ArrayObject;
use Cake\Core\Configure;
use Cake\Event\Event;
use FileStorage\Model\Table\FileStorageTable;
use FileStorage\Test\TestCase\FileStorageTestCase;
use FileStorage\Test\TestCase\FileStorageTestTable;
use Laminas\Diactoros\UploadedFile;

/**
Expand Down Expand Up @@ -37,7 +37,7 @@ public function setUp(): void
parent::setUp();

$this->getTableLocator()->clear();
$this->FileStorage = $this->getTableLocator()->get(FileStorageTestTable::class);
$this->FileStorage = $this->getTableLocator()->get(FileStorageTable::class);

$this->FileStorage->addBehavior(
'FileStorage.FileStorage',
Expand Down
27 changes: 27 additions & 0 deletions tests/TestCase/Model/Entity/FileStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,33 @@

class FileStorageTest extends FileStorageTestCase
{
/**
* @return void
*/
public function testNew(): void
{
$image = $this->FileStorage->newEntity([
'filename' => 'testimage.jpg',
'model' => 'Test',
'foreign_key' => 1,
'path' => 'test/path/testimage.jpg',
'extension' => 'jpg',
'adapter' => 'Local',
'variants' => [
't150' => [
'path' => 'test/path/testimage.c3f33c2a.jpg',
'url' => '',
],
],
'metadata' => [
'foo' => 'bar',
],
]);

$this->assertNotEmpty($image->variants);
$this->assertNotEmpty($image->metadata);
}

/**
* @return void
*/
Expand Down
8 changes: 2 additions & 6 deletions tests/TestCase/View/Helper/ImageHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,14 @@ public function tearDown(): void
}

/**
* testImageUrl
*
* @return void
*/
public function testImageUrl()
{
$image = $this->FileStorage->newEntity([
'id' => 'e479b480-f60b-11e1-a21f-0800200c9a66',
'filename' => 'testimage.jpg',
'model' => 'Test',
'foreign_key' => 1,
'path' => 'test/path/testimage.jpg',
'extension' => 'jpg',
'adapter' => 'Local',
Expand All @@ -85,7 +83,7 @@ public function testImageUrl()
'url' => '',
],
],
], ['accessibleFields' => ['*' => true]]);
]);

$result = $this->helper->imageUrl($image, 't150', ['pathPrefix' => '/src/']);
$this->assertEquals('/src/test/path/testimage.c3f33c2a.jpg', $result);
Expand All @@ -95,8 +93,6 @@ public function testImageUrl()
}

/**
* testImage
*
* @return void
*/
public function testImageUrlInvalidArgumentException()
Expand Down

0 comments on commit 79938d5

Please sign in to comment.