Skip to content

Commit 164950c

Browse files
BB-16898: Exception on inaccessible brand route (#28365)
1 parent b048597 commit 164950c

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

src/Oro/Bundle/ProductBundle/Controller/Frontend/BrandController.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
namespace Oro\Bundle\ProductBundle\Controller\Frontend;
44

5-
use Oro\Bundle\ProductBundle\Entity\Product;
5+
use Oro\Bundle\ProductBundle\Entity\Brand;
66
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
77
use Symfony\Component\HttpFoundation\Request;
8+
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
89
use Symfony\Component\Routing\Annotation\Route;
910

11+
/**
12+
* Frontend product brand controller.
13+
*/
1014
class BrandController extends Controller
1115
{
1216
const GRID_NAME = 'frontend-brand-search-grid';
@@ -20,7 +24,7 @@ class BrandController extends Controller
2024
*/
2125
public function indexAction()
2226
{
23-
return [];
27+
throw new NotFoundHttpException();
2428
}
2529

2630
/**
@@ -35,6 +39,6 @@ public function indexAction()
3539
*/
3640
public function viewAction(Request $request, Brand $brand)
3741
{
38-
return [];
42+
throw new NotFoundHttpException();
3943
}
4044
}

src/Oro/Bundle/ProductBundle/Resources/config/oro/routing.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ oro_product_frontend_product:
2020
options:
2121
frontend: true
2222

23+
oro_product_frontend_brand:
24+
resource: "@OroProductBundle/Controller/Frontend/BrandController.php"
25+
type: annotation
26+
prefix: /brand
27+
options:
28+
frontend: true
29+
2330
oro_product_frontend_product_ajax:
2431
resource: "@OroProductBundle/Controller/Frontend/AjaxProductController.php"
2532
type: annotation
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Oro\Bundle\ProductBundle\Tests\Functional\Controller\Frontend;
4+
5+
use Oro\Bundle\FrontendTestFrameworkBundle\Migrations\Data\ORM\LoadCustomerUserData;
6+
use Oro\Bundle\ProductBundle\Tests\Functional\DataFixtures\LoadBrandData;
7+
use Oro\Bundle\TestFrameworkBundle\Test\WebTestCase;
8+
9+
class BrandController extends WebTestCase
10+
{
11+
protected function setUp(): void
12+
{
13+
$this->initClient(
14+
[],
15+
$this->generateBasicAuthHeader(LoadCustomerUserData::AUTH_USER, LoadCustomerUserData::AUTH_PW)
16+
);
17+
$this->loadFixtures([LoadBrandData::class]);
18+
}
19+
20+
public function testIndexAction(): void
21+
{
22+
$this->client->request('GET', $this->getUrl('oro_product_frontend_brand_index'));
23+
$result = $this->client->getResponse();
24+
$this->assertHtmlResponseStatusCodeEquals($result, 404);
25+
}
26+
27+
public function testViewAction(): void
28+
{
29+
$brandId = $this->getReference(LoadBrandData::BRAND_1)->getId();
30+
$this->client->request('GET', $this->getUrl('oro_product_frontend_brand_view', ['id' => $brandId]));
31+
$result = $this->client->getResponse();
32+
$this->assertHtmlResponseStatusCodeEquals($result, 404);
33+
}
34+
}

0 commit comments

Comments
 (0)