Skip to content

Commit

Permalink
Merge pull request #4019 from thangnnmd/unitTest_BcFrontMiddleware_pr…
Browse files Browse the repository at this point in the history
…ocess

BcFrontMiddleware::process
  • Loading branch information
HungDV2022 authored Nov 25, 2024
2 parents 2aa02b9 + 768f24b commit 752569a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/baser-core/src/Middleware/BcFrontMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class BcFrontMiddleware implements MiddlewareInterface
* @return ResponseInterface
* @checked
* @noTodo
* @unitTest
*/
public function process(
ServerRequestInterface $request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,32 @@ public function test_setCurrent(): void
$this->assertNotEmpty($request->getAttribute('currentSite'));
}

/**
* Test process
*/
public function test_process(): void
{
ContentFactory::make([
'id' => 1,
'entity_id' => 1,
'url' => '/',
'site_id' => 1,
'status' => true,
])->persist();
SiteFactory::make([
'id' => 1,
'name' => '',
'title' => 'baserCMS inc.',
'status' => true,
])->persist();
$request = $this->getRequest()->withAttribute('isRequestView', true)->withQueryParams([
'Site' => SiteFactory::get(1),
'Content' => ContentFactory::get(1)
]);

$rs = $this->execPrivateMethod($this->BcFrontMiddleware, 'setCurrent', [$request]);
$this->assertNotEmpty($rs->getAttribute('currentContent'));
$this->assertNotEmpty($rs->getAttribute('currentSite'));
}

}

0 comments on commit 752569a

Please sign in to comment.