mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
Bundle - getBundleViewPath() method - return path using namespaced syntax
This commit is contained in:
@@ -83,6 +83,42 @@ class BundleTest extends BaseTestCase
|
||||
self::assertEquals($expected, Bundle::getBundleViewPath($viewPath, $bundleName, $extension));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $emptyValue Empty value, e.g. ""
|
||||
*
|
||||
* @throws IncorrectBundleNameException
|
||||
* @dataProvider provideEmptyValue
|
||||
*/
|
||||
public function testGetShortBundleNameUsingEmptyValue($emptyValue)
|
||||
{
|
||||
$this->setExpectedException(IncorrectBundleNameException::class);
|
||||
Bundle::getShortBundleName($emptyValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $bundleName Full name of the bundle, e.g. "MyExtraBundle"
|
||||
*
|
||||
* @throws IncorrectBundleNameException
|
||||
* @dataProvider provideIncorrectBundleName
|
||||
*/
|
||||
public function testGetShortBundleNameUsingIncorrectBundleName($bundleName)
|
||||
{
|
||||
$this->setExpectedException(IncorrectBundleNameException::class);
|
||||
Bundle::getShortBundleName($bundleName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fullBundleName Full name of the bundle, e.g. "MyExtraBundle"
|
||||
* @param string $shortBundleName Short name of bundle (without "Bundle")
|
||||
*
|
||||
* @throws IncorrectBundleNameException
|
||||
* @dataProvider provideFullAndShortBundleName
|
||||
*/
|
||||
public function testGetShortBundleName($fullBundleName, $shortBundleName)
|
||||
{
|
||||
self::assertEquals($shortBundleName, Bundle::getShortBundleName($fullBundleName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides empty path of the view / template and/or name of bundle
|
||||
*
|
||||
@@ -137,21 +173,21 @@ class BundleTest extends BaseTestCase
|
||||
public function provideViewPathAndBundle()
|
||||
{
|
||||
yield[
|
||||
':User',
|
||||
'User',
|
||||
'MyExtraBundle',
|
||||
'MyExtraBundle::User.html.twig',
|
||||
'@MyExtra/User.html.twig',
|
||||
];
|
||||
|
||||
yield[
|
||||
'User:Active',
|
||||
'MyExtraBundle',
|
||||
'MyExtraBundle:User:Active.html.twig',
|
||||
'@MyExtra/User/Active.html.twig',
|
||||
];
|
||||
|
||||
yield[
|
||||
'User:Active',
|
||||
'MySuperExtraGorgeousBundle',
|
||||
'MySuperExtraGorgeousBundle:User:Active.html.twig',
|
||||
'@MySuperExtraGorgeous/User/Active.html.twig',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -173,7 +209,45 @@ class BundleTest extends BaseTestCase
|
||||
'User:Active',
|
||||
'MyExtraBundle',
|
||||
'js.twig',
|
||||
'MyExtraBundle:User:Active.js.twig',
|
||||
'@MyExtra/User/Active.js.twig',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides incorrect name of bundle
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideIncorrectBundleName()
|
||||
{
|
||||
yield[
|
||||
'myExtra',
|
||||
];
|
||||
|
||||
yield[
|
||||
'MyExtra',
|
||||
];
|
||||
|
||||
yield[
|
||||
'MySuperExtraGorgeous',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides full and short name of bundle
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideFullAndShortBundleName()
|
||||
{
|
||||
yield[
|
||||
'MyExtraBundle',
|
||||
'MyExtra',
|
||||
];
|
||||
|
||||
yield[
|
||||
'MySuperExtraGorgeousBundle',
|
||||
'MySuperExtraGorgeous',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,6 +294,11 @@ class RegexTest extends BaseTestCase
|
||||
self::assertEquals($expected, Regex::isValidBundleName($bundleName));
|
||||
}
|
||||
|
||||
public function testGetBundleNamePattern()
|
||||
{
|
||||
self::assertEquals('/^(([A-Z]{1}[a-z0-9]+)((?2))*)(Bundle)$/', Regex::getBundleNamePattern());
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides name of bundle and information if it's valid name
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user