Skip to content

Commit 61e6ec2

Browse files
kamartonvjiksamdarkarogachev
authored
tests added (ViewRenderer#extractControllerName) (#60)
* tests added (ViewRenderer#extractControllerName) * fix tests * fix * .editorconfig * changelog * Update CHANGELOG.md Co-authored-by: Alexander Makarov <[email protected]> * Update tests/ViewRendererTest.php * Update tests/ViewRendererTest.php * Update tests/ViewRendererTest.php * Update tests/ViewRendererTest.php Co-authored-by: Sergei Predvoditelev <[email protected]> Co-authored-by: Sergei Predvoditelev <[email protected]> Co-authored-by: Alexander Makarov <[email protected]> Co-authored-by: Alexey Rogachev <[email protected]>
1 parent 999a9e7 commit 61e6ec2

File tree

11 files changed

+140
-25
lines changed

11 files changed

+140
-25
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ indent_style = space
1010
indent_size = 4
1111
trim_trailing_whitespace = true
1212

13+
[*.php]
14+
ij_php_space_before_short_closure_left_parenthesis = true
15+
ij_php_space_after_type_cast = true
16+
1317
[*.md]
1418
trim_trailing_whitespace = false
1519

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 5.0.1 under development
44

5-
- no changes in this release.
5+
- Bug #61: Fixed getting incorrect controller name based on controller instance (@vjik, @kamarton)
66

77
## 5.0.0 July 23, 2022
88

src/ViewRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ private function extractControllerName(object $controller): string
561561
return $cache[$class];
562562
}
563563

564-
$regexp = '/((?<=controller\\\|s\\\)(?:[\w\\\]+)|(?:[a-z]+))controller/iuU';
564+
$regexp = '/((?<=controller\\\|controllers\\\)(?:[\w\\\]+)|(?:[a-z]+))controller/iuU';
565565
if (!preg_match($regexp, $class, $m) || empty($m[1])) {
566566
throw new RuntimeException('Cannot detect controller name.');
567567
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Yiisoft\Yii\View\Tests\Support\Controller\SubNamespace;
6+
7+
final class FakeController
8+
{
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Yiisoft\Yii\View\Tests\Support\Controller\SubNamespace\SubNamespace2;
6+
7+
final class FakeController
8+
{
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Yiisoft\Yii\View\Tests\Support\Controllers\SubNamespace;
6+
7+
final class FakeController
8+
{
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Yiisoft\Yii\View\Tests\Support\Controllers\SubNamespace\SubNamespace2;
6+
7+
final class FakeController
8+
{
9+
}

tests/Support/FakeCntrl.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Yiisoft\Yii\View\Tests\Support;
6+
7+
final class FakeCntrl
8+
{
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Yiisoft\Yii\View\Tests\Support\NotCntrls\SubNamespace;
6+
7+
final class FakeCntrl
8+
{
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Yiisoft\Yii\View\Tests\Support\NotCntrls\SubNamespace;
6+
7+
final class FakeController
8+
{
9+
}

0 commit comments

Comments
 (0)