Skip to content

Commit

Permalink
Add unitTest_BcUploadHelper_getBasePath (#3835)
Browse files Browse the repository at this point in the history
Co-authored-by: thangnn <[email protected]>
  • Loading branch information
thangnnmd and thangnn authored Sep 23, 2024
1 parent 1ae08e3 commit f827f35
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/baser-core/src/View/Helper/BcUploadHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ public function uploadImage($fieldName, $entity, $options = [])
* @return string パス
* @checked
* @noTodo
* @unitTest
*/
public function getBasePath($settings, $isTheme = false)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php
namespace BcUploader\Test\TestCase\View\Helper;
use App\View\AppView;
use BaserCore\View\Helper\BcUploadHelper;
use BcUploader\Test\Factory\UploaderFileFactory;
use BcUploader\View\Helper\UploaderHelper;
use BaserCore\TestSuite\BcTestCase;
use Cake\Event\Event;
use Cake\I18n\FrozenTime;
use Cake\View\View;

/**
* baserCMS : Based Website Development Project <https://basercms.net>
Expand Down Expand Up @@ -151,4 +153,29 @@ public static function isPublishDataProvider()
[new FrozenTime('now'), new FrozenTime('now'), false]
];
}

/**
* test getBasePath
* @param $settings
* @param $isTheme
* @param $expected
* @dataProvider getBasePathDataProvider
*/
public function testGetBasePath($settings, $isTheme, $expected)
{
$helper = new BcUploadHelper(new View());

$result = $helper->getBasePath($settings, $isTheme);
$this->assertEquals($expected, $result);
}

public static function getBasePathDataProvider()
{
return [
[['saveDir' => 'uploads/images'], false, '/files/uploads/images/'],
[['saveDir' => 'uploads/images'], true, '/bc_front/files/uploads/images/'],
[['saveDir' => 'documents/files'], false, '/files/documents/files/'],
[['saveDir' => 'documents/files'], true, '/bc_front/files/documents/files/'],
];
}
}

0 comments on commit f827f35

Please sign in to comment.