Skip to content

Commit

Permalink
Merge pull request #4017 from thangnnmd/unitTest_BcBlogViewEventListe…
Browse files Browse the repository at this point in the history
…ner_leftOfToolbar

BcBlogViewEventListener::leftOfToolbar
  • Loading branch information
HungDV2022 authored Nov 15, 2024
2 parents e9c55db + d03302d commit ee46dfc
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/bc-blog/src/Event/BcBlogViewEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class BcBlogViewEventListener extends \BaserCore\Event\BcViewEventListener
* @param Event $event
* @checked
* @noTodo
* @unitTest
*/
public function leftOfToolbar(Event $event)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use BaserCore\Test\Factory\ContentFactory;
use BaserCore\Test\Scenario\InitAppScenario;
use BaserCore\TestSuite\BcTestCase;
use BaserCore\View\BcAdminAppView;
use BcBlog\Event\BcBlogViewEventListener;
use BcBlog\Test\Factory\BlogContentFactory;
use Cake\Core\Configure;
Expand Down Expand Up @@ -43,6 +44,7 @@ public function setUp(): void
parent::setUp();
$this->Listener = new BcBlogViewEventListener();
$this->loadFixtureScenario(InitAppScenario::class);

}

/**
Expand Down Expand Up @@ -117,4 +119,42 @@ public function testSetAdminMenu(): void
$this->assertEquals('blog-content', $config['BlogContent1']['type']);
}

/**
* Test leftOfToolbar
*
* @return void
*/

public function testLeftOfToolbar(): void
{
//with isAdminSystem false
$this->loginAdmin($this->getRequest('/abc'));
$View = new BcAdminAppView();
ob_start();
$this->Listener->leftOfToolbar(new Event('leftOfToolbar', $View));
$result = ob_get_clean();
$this->assertEmpty($result);

//with isAdminSystem true
$this->loginAdmin($this->getRequest('/'));
BlogContentFactory::make([
'id' => '1',
'template' => 'default',
'use_content' => '1'
])->persist();
ContentFactory::make([
'id' => 1,
'url' => '/',
'plugin' => 'BcBlog',
'type' => 'BlogContent',
'site_id' => 1,
'entity_id' => 1,
])->persist();
$View = new BcAdminAppView();
ob_start();
$this->Listener->leftOfToolbar(new Event('leftOfToolbar', $View));
$result = ob_get_clean();
$this->assertNotNull($result);
}

}

0 comments on commit ee46dfc

Please sign in to comment.