mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 17:41:50 +01:00
Reformat code automatically
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,7 @@
|
||||
|
||||
namespace Meritoo\Test\Common\Utilities;
|
||||
|
||||
use Generator;
|
||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||
use Meritoo\Common\Utilities\Bootstrap4CssSelector;
|
||||
|
||||
@@ -18,28 +19,145 @@ use Meritoo\Common\Utilities\Bootstrap4CssSelector;
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\Bootstrap4CssSelector
|
||||
* @covers \Meritoo\Common\Utilities\Bootstrap4CssSelector
|
||||
*/
|
||||
class Bootstrap4CssSelectorTest extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* Provides name of form and expected selector
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideFormNameAndSelector()
|
||||
{
|
||||
yield [
|
||||
'test',
|
||||
'form[name="test"] .form-group',
|
||||
];
|
||||
|
||||
yield [
|
||||
'test-123-test-456',
|
||||
'form[name="test-123-test-456"] .form-group',
|
||||
];
|
||||
|
||||
yield [
|
||||
'test_something_098_different',
|
||||
'form[name="test_something_098_different"] .form-group',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides name of form, name of field and expected selector
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideFormNameFieldNameAndSelector()
|
||||
{
|
||||
yield [
|
||||
'test',
|
||||
'test',
|
||||
'form[name="test"] label[for="test"] .invalid-feedback .form-error-message',
|
||||
];
|
||||
|
||||
yield [
|
||||
'test-123-test-456',
|
||||
'great-000-field',
|
||||
'form[name="test-123-test-456"] label[for="great-000-field"] .invalid-feedback .form-error-message',
|
||||
];
|
||||
|
||||
yield [
|
||||
'test_something_098_different',
|
||||
'this-is-the-123789-field',
|
||||
'form[name="test_something_098_different"] label[for="this-is-the-123789-field"] .invalid-feedback .form-error-message',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides name of form, index/position of the field-set and expected selector
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideFormNameFieldSetIndexAndSelector()
|
||||
{
|
||||
yield [
|
||||
'test',
|
||||
0,
|
||||
'form[name="test"] fieldset:nth-of-type(0) legend.col-form-label .invalid-feedback .form-error-message',
|
||||
];
|
||||
|
||||
yield [
|
||||
'test-123-test-456',
|
||||
1,
|
||||
'form[name="test-123-test-456"] fieldset:nth-of-type(1) legend.col-form-label .invalid-feedback .form-error-message',
|
||||
];
|
||||
|
||||
yield [
|
||||
'test_something_098_different',
|
||||
1245,
|
||||
'form[name="test_something_098_different"] fieldset:nth-of-type(1245) legend.col-form-label .invalid-feedback .form-error-message',
|
||||
];
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Bootstrap4CssSelector::class);
|
||||
}
|
||||
|
||||
public function testGetFieldErrorContainerSelector()
|
||||
{
|
||||
static::assertSame('.invalid-feedback .form-error-message', Bootstrap4CssSelector::getFieldErrorContainerSelector());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $formName Name of form (value of the "name" attribute)
|
||||
* @param string $fieldName Name of field (value of the "name" attribute)
|
||||
* @param string $expected Expected selector
|
||||
*
|
||||
* @dataProvider provideFormNameFieldNameAndSelector
|
||||
*/
|
||||
public function testGetFieldErrorSelector($formName, $fieldName, $expected)
|
||||
{
|
||||
static::assertSame($expected, Bootstrap4CssSelector::getFieldErrorSelector($formName, $fieldName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $emptyValue Name of field (value of the "name" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function testGetFieldErrorSelectorUsingEmptyFieldName($emptyValue)
|
||||
{
|
||||
$formName = 'test';
|
||||
static::assertSame('', Bootstrap4CssSelector::getFieldErrorSelector($formName, $emptyValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $emptyValue Name of form (value of the "name" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function testGetRadioButtonErrorSelectorUsingEmptyFormName($emptyValue)
|
||||
public function testGetFieldErrorSelectorUsingEmptyFormName($emptyValue)
|
||||
{
|
||||
$fieldSetIndex = 1;
|
||||
static::assertSame('', Bootstrap4CssSelector::getRadioButtonErrorSelector($emptyValue, $fieldSetIndex));
|
||||
$fieldName = 'test';
|
||||
static::assertSame('', Bootstrap4CssSelector::getFieldErrorSelector($emptyValue, $fieldName));
|
||||
}
|
||||
|
||||
public function testGetRadioButtonErrorSelectorUsingNegativeFieldSetIndex()
|
||||
/**
|
||||
* @param string $formName Name of form (value of the "name" attribute)
|
||||
* @param string $expected Expected selector
|
||||
*
|
||||
* @dataProvider provideFormNameAndSelector
|
||||
*/
|
||||
public function testGetFieldGroupSelector($formName, $expected)
|
||||
{
|
||||
static::assertSame('', Bootstrap4CssSelector::getRadioButtonErrorSelector('test-test', -1));
|
||||
static::assertSame($expected, Bootstrap4CssSelector::getFieldGroupSelector($formName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $emptyValue Name of form (value of the "name" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function testGetFieldGroupSelectorUsingEmptyFormName($emptyValue)
|
||||
{
|
||||
static::assertSame('', Bootstrap4CssSelector::getFieldGroupSelector($emptyValue));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,131 +176,14 @@ class Bootstrap4CssSelectorTest extends BaseTestCase
|
||||
* @param string $emptyValue Name of form (value of the "name" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function testGetFieldErrorSelectorUsingEmptyFormName($emptyValue)
|
||||
public function testGetRadioButtonErrorSelectorUsingEmptyFormName($emptyValue)
|
||||
{
|
||||
$fieldName = 'test';
|
||||
static::assertSame('', Bootstrap4CssSelector::getFieldErrorSelector($emptyValue, $fieldName));
|
||||
$fieldSetIndex = 1;
|
||||
static::assertSame('', Bootstrap4CssSelector::getRadioButtonErrorSelector($emptyValue, $fieldSetIndex));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $emptyValue Name of field (value of the "name" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function testGetFieldErrorSelectorUsingEmptyFieldName($emptyValue)
|
||||
public function testGetRadioButtonErrorSelectorUsingNegativeFieldSetIndex()
|
||||
{
|
||||
$formName = 'test';
|
||||
static::assertSame('', Bootstrap4CssSelector::getFieldErrorSelector($formName, $emptyValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $formName Name of form (value of the "name" attribute)
|
||||
* @param string $fieldName Name of field (value of the "name" attribute)
|
||||
* @param string $expected Expected selector
|
||||
*
|
||||
* @dataProvider provideFormNameFieldNameAndSelector
|
||||
*/
|
||||
public function testGetFieldErrorSelector($formName, $fieldName, $expected)
|
||||
{
|
||||
static::assertSame($expected, Bootstrap4CssSelector::getFieldErrorSelector($formName, $fieldName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $emptyValue Name of form (value of the "name" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function testGetFieldGroupSelectorUsingEmptyFormName($emptyValue)
|
||||
{
|
||||
static::assertSame('', Bootstrap4CssSelector::getFieldGroupSelector($emptyValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $formName Name of form (value of the "name" attribute)
|
||||
* @param string $expected Expected selector
|
||||
*
|
||||
* @dataProvider provideFormNameAndSelector
|
||||
*/
|
||||
public function testGetFieldGroupSelector($formName, $expected)
|
||||
{
|
||||
static::assertSame($expected, Bootstrap4CssSelector::getFieldGroupSelector($formName));
|
||||
}
|
||||
|
||||
public function testGetFieldErrorContainerSelector()
|
||||
{
|
||||
static::assertSame('.invalid-feedback .form-error-message', Bootstrap4CssSelector::getFieldErrorContainerSelector());
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides name of form, index/position of the field-set and expected selector
|
||||
*
|
||||
* @return \Generator
|
||||
*/
|
||||
public function provideFormNameFieldSetIndexAndSelector()
|
||||
{
|
||||
yield[
|
||||
'test',
|
||||
0,
|
||||
'form[name="test"] fieldset:nth-of-type(0) legend.col-form-label .invalid-feedback .form-error-message',
|
||||
];
|
||||
|
||||
yield[
|
||||
'test-123-test-456',
|
||||
1,
|
||||
'form[name="test-123-test-456"] fieldset:nth-of-type(1) legend.col-form-label .invalid-feedback .form-error-message',
|
||||
];
|
||||
|
||||
yield[
|
||||
'test_something_098_different',
|
||||
1245,
|
||||
'form[name="test_something_098_different"] fieldset:nth-of-type(1245) legend.col-form-label .invalid-feedback .form-error-message',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides name of form, name of field and expected selector
|
||||
*
|
||||
* @return \Generator
|
||||
*/
|
||||
public function provideFormNameFieldNameAndSelector()
|
||||
{
|
||||
yield[
|
||||
'test',
|
||||
'test',
|
||||
'form[name="test"] label[for="test"] .invalid-feedback .form-error-message',
|
||||
];
|
||||
|
||||
yield[
|
||||
'test-123-test-456',
|
||||
'great-000-field',
|
||||
'form[name="test-123-test-456"] label[for="great-000-field"] .invalid-feedback .form-error-message',
|
||||
];
|
||||
|
||||
yield[
|
||||
'test_something_098_different',
|
||||
'this-is-the-123789-field',
|
||||
'form[name="test_something_098_different"] label[for="this-is-the-123789-field"] .invalid-feedback .form-error-message',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides name of form and expected selector
|
||||
*
|
||||
* @return \Generator
|
||||
*/
|
||||
public function provideFormNameAndSelector()
|
||||
{
|
||||
yield[
|
||||
'test',
|
||||
'form[name="test"] .form-group',
|
||||
];
|
||||
|
||||
yield[
|
||||
'test-123-test-456',
|
||||
'form[name="test-123-test-456"] .form-group',
|
||||
];
|
||||
|
||||
yield[
|
||||
'test_something_098_different',
|
||||
'form[name="test_something_098_different"] .form-group',
|
||||
];
|
||||
static::assertSame('', Bootstrap4CssSelector::getRadioButtonErrorSelector('test-test', -1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,15 +20,174 @@ use Meritoo\Common\Utilities\Bundle;
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\Bundle
|
||||
* @covers \Meritoo\Common\Utilities\Bundle
|
||||
*/
|
||||
class BundleTest extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* Provides empty path of the view / template and/or name of bundle
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideEmptyViewPathAndBundle()
|
||||
{
|
||||
yield [
|
||||
'',
|
||||
'',
|
||||
];
|
||||
|
||||
yield [
|
||||
'test',
|
||||
'',
|
||||
];
|
||||
|
||||
yield [
|
||||
'',
|
||||
'test',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides full and short name of bundle
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideFullAndShortBundleName()
|
||||
{
|
||||
yield [
|
||||
'MyExtraBundle',
|
||||
'MyExtra',
|
||||
];
|
||||
|
||||
yield [
|
||||
'MySuperExtraGorgeousBundle',
|
||||
'MySuperExtraGorgeous',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides incorrect name of bundle
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideIncorrectBundleName()
|
||||
{
|
||||
yield [
|
||||
'myExtra',
|
||||
];
|
||||
|
||||
yield [
|
||||
'MyExtra',
|
||||
];
|
||||
|
||||
yield [
|
||||
'MySuperExtraGorgeous',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides path of the view / template and name of bundle
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideViewPathAndBundle()
|
||||
{
|
||||
yield [
|
||||
'User',
|
||||
'MyExtraBundle',
|
||||
'@MyExtra/User.html.twig',
|
||||
];
|
||||
|
||||
yield [
|
||||
'User:Active',
|
||||
'MyExtraBundle',
|
||||
'@MyExtra/User/Active.html.twig',
|
||||
];
|
||||
|
||||
yield [
|
||||
'User:Active',
|
||||
'MySuperExtraGorgeousBundle',
|
||||
'@MySuperExtraGorgeous/User/Active.html.twig',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides path of the view / template, name of bundle and extension of the view / template
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideViewPathAndBundleAndExtension()
|
||||
{
|
||||
yield [
|
||||
'User:Active',
|
||||
'MyExtraBundle',
|
||||
'',
|
||||
null,
|
||||
];
|
||||
|
||||
yield [
|
||||
'User:Active',
|
||||
'MyExtraBundle',
|
||||
'js.twig',
|
||||
'@MyExtra/User/Active.js.twig',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides path of the view / template and incorrect name of bundle
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideViewPathAndIncorrectBundleName()
|
||||
{
|
||||
yield [
|
||||
'User:Active',
|
||||
'myExtra',
|
||||
];
|
||||
|
||||
yield [
|
||||
'User:Active',
|
||||
'MyExtra',
|
||||
];
|
||||
|
||||
yield [
|
||||
'User:Active',
|
||||
'MySuperExtraGorgeous',
|
||||
];
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Bundle::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $viewPath Path of the view / template, e.g. "MyDirectory/my-template"
|
||||
* @param string $bundleName Full name of the bundle, e.g. "MyExtraBundle"
|
||||
* @param string $extension (optional) Extension of the view / template
|
||||
* @param string $expected Expected path to view / template
|
||||
*
|
||||
* @throws IncorrectBundleNameException
|
||||
* @dataProvider provideViewPathAndBundleAndExtension
|
||||
*/
|
||||
public function testGetBundleViewPathUsingCustomExtension($viewPath, $bundleName, $extension, $expected)
|
||||
{
|
||||
self::assertEquals($expected, Bundle::getBundleViewPath($viewPath, $bundleName, $extension));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $viewPath Path of the view / template, e.g. "MyDirectory/my-template"
|
||||
* @param string $bundleName Full name of the bundle, e.g. "MyExtraBundle"
|
||||
* @param string $expected Expected path to view / template
|
||||
*
|
||||
* @throws IncorrectBundleNameException
|
||||
* @dataProvider provideViewPathAndBundle
|
||||
*/
|
||||
public function testGetBundleViewPathUsingDefaultExtension($viewPath, $bundleName, $expected)
|
||||
{
|
||||
self::assertEquals($expected, Bundle::getBundleViewPath($viewPath, $bundleName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $viewPath Path of the view / template, e.g. "MyDirectory/my-template"
|
||||
* @param string $bundleName Full name of the bundle, e.g. "MyExtraBundle"
|
||||
@@ -50,7 +209,7 @@ class BundleTest extends BaseTestCase
|
||||
public function testGetBundleViewPathUsingIncorrectBundleName($viewPath, $bundleName)
|
||||
{
|
||||
$template = 'Name of bundle \'%s\' is incorrect. It should start with big letter and end with "Bundle". Is'
|
||||
. ' there everything ok?';
|
||||
.' there everything ok?';
|
||||
|
||||
$this->expectException(IncorrectBundleNameException::class);
|
||||
$this->expectExceptionMessage(sprintf($template, $bundleName));
|
||||
@@ -59,30 +218,15 @@ class BundleTest extends BaseTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $viewPath Path of the view / template, e.g. "MyDirectory/my-template"
|
||||
* @param string $bundleName Full name of the bundle, e.g. "MyExtraBundle"
|
||||
* @param string $expected Expected path to view / template
|
||||
* @param string $fullBundleName Full name of the bundle, e.g. "MyExtraBundle"
|
||||
* @param string $shortBundleName Short name of bundle (without "Bundle")
|
||||
*
|
||||
* @throws IncorrectBundleNameException
|
||||
* @dataProvider provideViewPathAndBundle
|
||||
* @dataProvider provideFullAndShortBundleName
|
||||
*/
|
||||
public function testGetBundleViewPathUsingDefaultExtension($viewPath, $bundleName, $expected)
|
||||
public function testGetShortBundleName($fullBundleName, $shortBundleName)
|
||||
{
|
||||
self::assertEquals($expected, Bundle::getBundleViewPath($viewPath, $bundleName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $viewPath Path of the view / template, e.g. "MyDirectory/my-template"
|
||||
* @param string $bundleName Full name of the bundle, e.g. "MyExtraBundle"
|
||||
* @param string $extension (optional) Extension of the view / template
|
||||
* @param string $expected Expected path to view / template
|
||||
*
|
||||
* @throws IncorrectBundleNameException
|
||||
* @dataProvider provideViewPathAndBundleAndExtension
|
||||
*/
|
||||
public function testGetBundleViewPathUsingCustomExtension($viewPath, $bundleName, $extension, $expected)
|
||||
{
|
||||
self::assertEquals($expected, Bundle::getBundleViewPath($viewPath, $bundleName, $extension));
|
||||
self::assertEquals($shortBundleName, Bundle::getShortBundleName($fullBundleName));
|
||||
}
|
||||
|
||||
public function testGetShortBundleNameUsingEmptyValue(): void
|
||||
@@ -102,148 +246,4 @@ class BundleTest extends BaseTestCase
|
||||
$this->expectException(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
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideEmptyViewPathAndBundle()
|
||||
{
|
||||
yield[
|
||||
'',
|
||||
'',
|
||||
];
|
||||
|
||||
yield[
|
||||
'test',
|
||||
'',
|
||||
];
|
||||
|
||||
yield[
|
||||
'',
|
||||
'test',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides path of the view / template and incorrect name of bundle
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideViewPathAndIncorrectBundleName()
|
||||
{
|
||||
yield[
|
||||
'User:Active',
|
||||
'myExtra',
|
||||
];
|
||||
|
||||
yield[
|
||||
'User:Active',
|
||||
'MyExtra',
|
||||
];
|
||||
|
||||
yield[
|
||||
'User:Active',
|
||||
'MySuperExtraGorgeous',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides path of the view / template and name of bundle
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideViewPathAndBundle()
|
||||
{
|
||||
yield[
|
||||
'User',
|
||||
'MyExtraBundle',
|
||||
'@MyExtra/User.html.twig',
|
||||
];
|
||||
|
||||
yield[
|
||||
'User:Active',
|
||||
'MyExtraBundle',
|
||||
'@MyExtra/User/Active.html.twig',
|
||||
];
|
||||
|
||||
yield[
|
||||
'User:Active',
|
||||
'MySuperExtraGorgeousBundle',
|
||||
'@MySuperExtraGorgeous/User/Active.html.twig',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides path of the view / template, name of bundle and extension of the view / template
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideViewPathAndBundleAndExtension()
|
||||
{
|
||||
yield[
|
||||
'User:Active',
|
||||
'MyExtraBundle',
|
||||
'',
|
||||
null,
|
||||
];
|
||||
|
||||
yield[
|
||||
'User:Active',
|
||||
'MyExtraBundle',
|
||||
'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',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ use Meritoo\Common\Utilities\Composer;
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\Composer
|
||||
* @covers \Meritoo\Common\Utilities\Composer
|
||||
*/
|
||||
class ComposerTest extends BaseTestCase
|
||||
{
|
||||
@@ -30,11 +30,40 @@ class ComposerTest extends BaseTestCase
|
||||
*/
|
||||
private $composerJsonPath;
|
||||
|
||||
/**
|
||||
* Provides names and values of existing nodes
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function getExistingNode(): Generator
|
||||
{
|
||||
yield [
|
||||
'name',
|
||||
'test/test',
|
||||
];
|
||||
|
||||
yield [
|
||||
'version',
|
||||
'1.0.2',
|
||||
];
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Composer::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $nodeName Name of existing node
|
||||
* @param string $nodeValue Value of existing node
|
||||
*
|
||||
* @dataProvider getExistingNode
|
||||
*/
|
||||
public function testGetValueExistingNode(string $nodeName, string $nodeValue): void
|
||||
{
|
||||
self::assertEquals($nodeValue, Composer::getValue($this->composerJsonPath, $nodeName));
|
||||
}
|
||||
|
||||
public function testGetValueNotExistingComposerJson(): void
|
||||
{
|
||||
self::assertNull(Composer::getValue('', ''));
|
||||
@@ -47,35 +76,6 @@ class ComposerTest extends BaseTestCase
|
||||
self::assertNull(Composer::getValue($this->composerJsonPath, 'not_existing_node'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $nodeName Name of existing node
|
||||
* @param string $nodeValue Value of existing node
|
||||
*
|
||||
* @dataProvider getExistingNode
|
||||
*/
|
||||
public function testGetValueExistingNode(string $nodeName, string $nodeValue): void
|
||||
{
|
||||
self::assertEquals($nodeValue, Composer::getValue($this->composerJsonPath, $nodeName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides names and values of existing nodes
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function getExistingNode(): Generator
|
||||
{
|
||||
yield[
|
||||
'name',
|
||||
'test/test',
|
||||
];
|
||||
|
||||
yield[
|
||||
'version',
|
||||
'1.0.2',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
namespace Meritoo\Test\Common\Utilities;
|
||||
|
||||
use Generator;
|
||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||
use Meritoo\Common\Utilities\CssSelector;
|
||||
|
||||
@@ -18,129 +19,152 @@ use Meritoo\Common\Utilities\CssSelector;
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\CssSelector
|
||||
* @covers \Meritoo\Common\Utilities\CssSelector
|
||||
*/
|
||||
class CssSelectorTest extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* Provides name of form and selector of the form
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideFormNameAndSelector()
|
||||
{
|
||||
yield [
|
||||
'test',
|
||||
'form[name="test"]',
|
||||
];
|
||||
|
||||
yield [
|
||||
'test-123-test-456',
|
||||
'form[name="test-123-test-456"]',
|
||||
];
|
||||
|
||||
yield [
|
||||
'test_something_098_different',
|
||||
'form[name="test_something_098_different"]',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides name of form, ID of field and expected selector of label
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideFormNameFieldIdAndLabelSelector()
|
||||
{
|
||||
yield [
|
||||
'test',
|
||||
'test',
|
||||
'form[name="test"] label[for="test"]',
|
||||
];
|
||||
|
||||
yield [
|
||||
'test-123-test-456',
|
||||
'great-000-field',
|
||||
'form[name="test-123-test-456"] label[for="great-000-field"]',
|
||||
];
|
||||
|
||||
yield [
|
||||
'test_something_098_different',
|
||||
'this-is-the-123789-field',
|
||||
'form[name="test_something_098_different"] label[for="this-is-the-123789-field"]',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides name of form, ID of field and expected selector
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideFormNameFieldIdAndSelector()
|
||||
{
|
||||
yield [
|
||||
'test',
|
||||
'test',
|
||||
'form[name="test"] input#test',
|
||||
];
|
||||
|
||||
yield [
|
||||
'test-123-test-456',
|
||||
'great-000-field',
|
||||
'form[name="test-123-test-456"] input#great-000-field',
|
||||
];
|
||||
|
||||
yield [
|
||||
'test_something_098_different',
|
||||
'this-is-the-123789-field',
|
||||
'form[name="test_something_098_different"] input#this-is-the-123789-field',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides name of form, name of field and expected selector
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideFormNameFieldNameAndSelector()
|
||||
{
|
||||
yield [
|
||||
'test',
|
||||
'test',
|
||||
'form[name="test"] input[name="test"]',
|
||||
];
|
||||
|
||||
yield [
|
||||
'test-123-test-456',
|
||||
'great-000-field',
|
||||
'form[name="test-123-test-456"] input[name="great-000-field"]',
|
||||
];
|
||||
|
||||
yield [
|
||||
'test_something_098_different',
|
||||
'this-is-the-123789-field',
|
||||
'form[name="test_something_098_different"] input[name="this-is-the-123789-field"]',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides name of form, index/position of the field-set and expected selector
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideFormNameFieldSetIndexAndSelector()
|
||||
{
|
||||
yield [
|
||||
'test',
|
||||
0,
|
||||
'form[name="test"] fieldset:nth-of-type(0)',
|
||||
];
|
||||
|
||||
yield [
|
||||
'test-123-test-456',
|
||||
1,
|
||||
'form[name="test-123-test-456"] fieldset:nth-of-type(1)',
|
||||
];
|
||||
|
||||
yield [
|
||||
'test_something_098_different',
|
||||
1245,
|
||||
'form[name="test_something_098_different"] fieldset:nth-of-type(1245)',
|
||||
];
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(CssSelector::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $emptyValue Name of form (value of the "name" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function testGetFormByNameSelectorUsingEmptyName($emptyValue)
|
||||
{
|
||||
static::assertSame('', CssSelector::getFormByNameSelector($emptyValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $formName Name of form (value of the "name" attribute)
|
||||
* @param string $expected Expected selector
|
||||
* @param string $formName Name of form (value of the "name" attribute)
|
||||
* @param int $fieldSetIndex Index/Position of the field-set
|
||||
* @param string $expected Expected selector
|
||||
*
|
||||
* @dataProvider provideFormNameAndSelector
|
||||
* @dataProvider provideFormNameFieldSetIndexAndSelector
|
||||
*/
|
||||
public function testGetFormByNameSelector($formName, $expected)
|
||||
public function testGetFieldSetByIndexSelector($formName, $fieldSetIndex, $expected)
|
||||
{
|
||||
static::assertSame($expected, CssSelector::getFormByNameSelector($formName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $emptyValue Name of form (value of the "name" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function testGetInputByNameSelectorUsingEmptyFormName($emptyValue)
|
||||
{
|
||||
$fieldName = 'test-test';
|
||||
static::assertSame('', CssSelector::getInputByNameSelector($emptyValue, $fieldName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $emptyValue Name of field (value of the "name" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function testGetInputByNameSelectorUsingEmptyFieldName($emptyValue)
|
||||
{
|
||||
$formName = 'test-test';
|
||||
static::assertSame('', CssSelector::getInputByNameSelector($formName, $emptyValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $formName Name of form (value of the "name" attribute)
|
||||
* @param string $fieldName Name of field (value of the "name" attribute)
|
||||
* @param string $expected Expected selector
|
||||
*
|
||||
* @dataProvider provideFormNameFieldNameAndSelector
|
||||
*/
|
||||
public function testGetInputByNameSelector($formName, $fieldName, $expected)
|
||||
{
|
||||
static::assertSame($expected, CssSelector::getInputByNameSelector($formName, $fieldName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $emptyValue Name of form (value of the "name" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function testGetInputByIdSelectorUsingEmptyFormName($emptyValue)
|
||||
{
|
||||
$fieldId = 'test-test';
|
||||
static::assertSame('', CssSelector::getInputByIdSelector($emptyValue, $fieldId));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $emptyValue ID of field (value of the "id" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function testGetInputByIdSelectorUsingEmptyFieldName($emptyValue)
|
||||
{
|
||||
$formName = 'test-test';
|
||||
static::assertSame('', CssSelector::getInputByIdSelector($formName, $emptyValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $formName Name of form (value of the "name" attribute)
|
||||
* @param string $fieldId ID of field (value of the "id" attribute)
|
||||
* @param string $expected Expected selector
|
||||
*
|
||||
* @dataProvider provideFormNameFieldIdAndSelector
|
||||
*/
|
||||
public function testGetInputByIdSelector($formName, $fieldId, $expected)
|
||||
{
|
||||
static::assertSame($expected, CssSelector::getInputByIdSelector($formName, $fieldId));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $emptyValue Name of form (value of the "name" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function testGetLabelSelectorUsingEmptyFormName($emptyValue)
|
||||
{
|
||||
$fieldId = 'test-test';
|
||||
static::assertSame('', CssSelector::getLabelSelector($emptyValue, $fieldId));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $emptyValue ID of field (value of the "id" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function testGetLabelSelectorUsingEmptyFieldId($emptyValue)
|
||||
{
|
||||
$formName = 'test-test';
|
||||
static::assertSame('', CssSelector::getLabelSelector($formName, $emptyValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $formName Name of form (value of the "name" attribute)
|
||||
* @param string $fieldId ID of field (value of the "id" attribute)
|
||||
* @param string $expected Expected selector
|
||||
*
|
||||
* @dataProvider provideFormNameFieldIdAndLabelSelector
|
||||
*/
|
||||
public function testGetLabelSelector($formName, $fieldId, $expected)
|
||||
{
|
||||
static::assertSame($expected, CssSelector::getLabelSelector($formName, $fieldId));
|
||||
static::assertSame($expected, CssSelector::getFieldSetByIndexSelector($formName, $fieldSetIndex));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,141 +183,118 @@ class CssSelectorTest extends BaseTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $formName Name of form (value of the "name" attribute)
|
||||
* @param int $fieldSetIndex Index/Position of the field-set
|
||||
* @param string $expected Expected selector
|
||||
* @param string $formName Name of form (value of the "name" attribute)
|
||||
* @param string $expected Expected selector
|
||||
*
|
||||
* @dataProvider provideFormNameFieldSetIndexAndSelector
|
||||
* @dataProvider provideFormNameAndSelector
|
||||
*/
|
||||
public function testGetFieldSetByIndexSelector($formName, $fieldSetIndex, $expected)
|
||||
public function testGetFormByNameSelector($formName, $expected)
|
||||
{
|
||||
static::assertSame($expected, CssSelector::getFieldSetByIndexSelector($formName, $fieldSetIndex));
|
||||
static::assertSame($expected, CssSelector::getFormByNameSelector($formName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides name of form and selector of the form
|
||||
*
|
||||
* @return \Generator
|
||||
* @param string $emptyValue Name of form (value of the "name" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function provideFormNameAndSelector()
|
||||
public function testGetFormByNameSelectorUsingEmptyName($emptyValue)
|
||||
{
|
||||
yield[
|
||||
'test',
|
||||
'form[name="test"]',
|
||||
];
|
||||
|
||||
yield[
|
||||
'test-123-test-456',
|
||||
'form[name="test-123-test-456"]',
|
||||
];
|
||||
|
||||
yield[
|
||||
'test_something_098_different',
|
||||
'form[name="test_something_098_different"]',
|
||||
];
|
||||
static::assertSame('', CssSelector::getFormByNameSelector($emptyValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides name of form, name of field and expected selector
|
||||
* @param string $formName Name of form (value of the "name" attribute)
|
||||
* @param string $fieldId ID of field (value of the "id" attribute)
|
||||
* @param string $expected Expected selector
|
||||
*
|
||||
* @return \Generator
|
||||
* @dataProvider provideFormNameFieldIdAndSelector
|
||||
*/
|
||||
public function provideFormNameFieldNameAndSelector()
|
||||
public function testGetInputByIdSelector($formName, $fieldId, $expected)
|
||||
{
|
||||
yield[
|
||||
'test',
|
||||
'test',
|
||||
'form[name="test"] input[name="test"]',
|
||||
];
|
||||
|
||||
yield[
|
||||
'test-123-test-456',
|
||||
'great-000-field',
|
||||
'form[name="test-123-test-456"] input[name="great-000-field"]',
|
||||
];
|
||||
|
||||
yield[
|
||||
'test_something_098_different',
|
||||
'this-is-the-123789-field',
|
||||
'form[name="test_something_098_different"] input[name="this-is-the-123789-field"]',
|
||||
];
|
||||
static::assertSame($expected, CssSelector::getInputByIdSelector($formName, $fieldId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides name of form, ID of field and expected selector of label
|
||||
*
|
||||
* @return \Generator
|
||||
* @param string $emptyValue ID of field (value of the "id" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function provideFormNameFieldIdAndLabelSelector()
|
||||
public function testGetInputByIdSelectorUsingEmptyFieldName($emptyValue)
|
||||
{
|
||||
yield[
|
||||
'test',
|
||||
'test',
|
||||
'form[name="test"] label[for="test"]',
|
||||
];
|
||||
|
||||
yield[
|
||||
'test-123-test-456',
|
||||
'great-000-field',
|
||||
'form[name="test-123-test-456"] label[for="great-000-field"]',
|
||||
];
|
||||
|
||||
yield[
|
||||
'test_something_098_different',
|
||||
'this-is-the-123789-field',
|
||||
'form[name="test_something_098_different"] label[for="this-is-the-123789-field"]',
|
||||
];
|
||||
$formName = 'test-test';
|
||||
static::assertSame('', CssSelector::getInputByIdSelector($formName, $emptyValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides name of form, index/position of the field-set and expected selector
|
||||
*
|
||||
* @return \Generator
|
||||
* @param string $emptyValue Name of form (value of the "name" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function provideFormNameFieldSetIndexAndSelector()
|
||||
public function testGetInputByIdSelectorUsingEmptyFormName($emptyValue)
|
||||
{
|
||||
yield[
|
||||
'test',
|
||||
0,
|
||||
'form[name="test"] fieldset:nth-of-type(0)',
|
||||
];
|
||||
|
||||
yield[
|
||||
'test-123-test-456',
|
||||
1,
|
||||
'form[name="test-123-test-456"] fieldset:nth-of-type(1)',
|
||||
];
|
||||
|
||||
yield[
|
||||
'test_something_098_different',
|
||||
1245,
|
||||
'form[name="test_something_098_different"] fieldset:nth-of-type(1245)',
|
||||
];
|
||||
$fieldId = 'test-test';
|
||||
static::assertSame('', CssSelector::getInputByIdSelector($emptyValue, $fieldId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides name of form, ID of field and expected selector
|
||||
* @param string $formName Name of form (value of the "name" attribute)
|
||||
* @param string $fieldName Name of field (value of the "name" attribute)
|
||||
* @param string $expected Expected selector
|
||||
*
|
||||
* @return \Generator
|
||||
* @dataProvider provideFormNameFieldNameAndSelector
|
||||
*/
|
||||
public function provideFormNameFieldIdAndSelector()
|
||||
public function testGetInputByNameSelector($formName, $fieldName, $expected)
|
||||
{
|
||||
yield[
|
||||
'test',
|
||||
'test',
|
||||
'form[name="test"] input#test',
|
||||
];
|
||||
static::assertSame($expected, CssSelector::getInputByNameSelector($formName, $fieldName));
|
||||
}
|
||||
|
||||
yield[
|
||||
'test-123-test-456',
|
||||
'great-000-field',
|
||||
'form[name="test-123-test-456"] input#great-000-field',
|
||||
];
|
||||
/**
|
||||
* @param string $emptyValue Name of field (value of the "name" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function testGetInputByNameSelectorUsingEmptyFieldName($emptyValue)
|
||||
{
|
||||
$formName = 'test-test';
|
||||
static::assertSame('', CssSelector::getInputByNameSelector($formName, $emptyValue));
|
||||
}
|
||||
|
||||
yield[
|
||||
'test_something_098_different',
|
||||
'this-is-the-123789-field',
|
||||
'form[name="test_something_098_different"] input#this-is-the-123789-field',
|
||||
];
|
||||
/**
|
||||
* @param string $emptyValue Name of form (value of the "name" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function testGetInputByNameSelectorUsingEmptyFormName($emptyValue)
|
||||
{
|
||||
$fieldName = 'test-test';
|
||||
static::assertSame('', CssSelector::getInputByNameSelector($emptyValue, $fieldName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $formName Name of form (value of the "name" attribute)
|
||||
* @param string $fieldId ID of field (value of the "id" attribute)
|
||||
* @param string $expected Expected selector
|
||||
*
|
||||
* @dataProvider provideFormNameFieldIdAndLabelSelector
|
||||
*/
|
||||
public function testGetLabelSelector($formName, $fieldId, $expected)
|
||||
{
|
||||
static::assertSame($expected, CssSelector::getLabelSelector($formName, $fieldId));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $emptyValue ID of field (value of the "id" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function testGetLabelSelectorUsingEmptyFieldId($emptyValue)
|
||||
{
|
||||
$formName = 'test-test';
|
||||
static::assertSame('', CssSelector::getLabelSelector($formName, $emptyValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $emptyValue Name of form (value of the "name" attribute)
|
||||
* @dataProvider provideEmptyScalarValue
|
||||
*/
|
||||
public function testGetLabelSelectorUsingEmptyFormName($emptyValue)
|
||||
{
|
||||
$fieldId = 'test-test';
|
||||
static::assertSame('', CssSelector::getLabelSelector($emptyValue, $fieldId));
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,7 @@ use Meritoo\Common\Utilities\GeneratorUtility;
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\GeneratorUtility
|
||||
* @covers \Meritoo\Common\Utilities\GeneratorUtility
|
||||
*/
|
||||
class GeneratorUtilityTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -20,10 +20,138 @@ use ReflectionException;
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\Locale
|
||||
* @covers \Meritoo\Common\Utilities\Locale
|
||||
*/
|
||||
class LocaleTest extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* Provides category
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideCategoryLanguageCodeAndExpectedLocale()
|
||||
{
|
||||
yield [
|
||||
LC_ALL,
|
||||
'fr',
|
||||
'',
|
||||
'fr_FR.UTF-8',
|
||||
];
|
||||
|
||||
yield [
|
||||
LC_COLLATE,
|
||||
'fr',
|
||||
'FR',
|
||||
'fr_FR.UTF-8',
|
||||
];
|
||||
|
||||
yield [
|
||||
LC_CTYPE,
|
||||
'en',
|
||||
'US',
|
||||
'en_US.UTF-8',
|
||||
];
|
||||
|
||||
yield [
|
||||
LC_NUMERIC,
|
||||
'en',
|
||||
'GB',
|
||||
'en_GB.UTF-8',
|
||||
];
|
||||
|
||||
yield [
|
||||
LC_MONETARY,
|
||||
'es',
|
||||
'',
|
||||
'es_ES.UTF-8',
|
||||
];
|
||||
|
||||
yield [
|
||||
LC_MONETARY,
|
||||
'es',
|
||||
'ES',
|
||||
'es_ES.UTF-8',
|
||||
];
|
||||
|
||||
yield [
|
||||
LC_TIME,
|
||||
'it',
|
||||
'',
|
||||
'it_IT.UTF-8',
|
||||
];
|
||||
|
||||
yield [
|
||||
LC_TIME,
|
||||
'it',
|
||||
'IT',
|
||||
'it_IT.UTF-8',
|
||||
];
|
||||
|
||||
yield [
|
||||
LC_TIME,
|
||||
'it',
|
||||
'it',
|
||||
'it_IT.UTF-8',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides language, encoding and country code
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideLanguageEncodingAndCountryCode()
|
||||
{
|
||||
yield [
|
||||
'fr',
|
||||
'',
|
||||
'',
|
||||
'fr_FR',
|
||||
];
|
||||
|
||||
yield [
|
||||
'fr',
|
||||
'',
|
||||
'UTF-8',
|
||||
'fr_FR.UTF-8',
|
||||
];
|
||||
|
||||
yield [
|
||||
'fr',
|
||||
'FR',
|
||||
'',
|
||||
'fr_FR',
|
||||
];
|
||||
|
||||
yield [
|
||||
'fr',
|
||||
'FR',
|
||||
'UTF-8',
|
||||
'fr_FR.UTF-8',
|
||||
];
|
||||
|
||||
yield [
|
||||
'en',
|
||||
'US',
|
||||
'',
|
||||
'en_US',
|
||||
];
|
||||
|
||||
yield [
|
||||
'en',
|
||||
'US',
|
||||
'UTF-8',
|
||||
'en_US.UTF-8',
|
||||
];
|
||||
|
||||
yield [
|
||||
'en',
|
||||
'US',
|
||||
'ISO-8859-1',
|
||||
'en_US.ISO-8859-1',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
@@ -32,56 +160,6 @@ class LocaleTest extends BaseTestCase
|
||||
static::assertHasNoConstructor(Locale::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $languageCode Empty value, e.g. ""
|
||||
* @dataProvider provideEmptyValue
|
||||
*/
|
||||
public function testGetLongFormEmptyLanguageCode($languageCode)
|
||||
{
|
||||
self::assertEquals('', Locale::getLongForm($languageCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $languageCode Language code, in ISO 639-1 format. Short form of the locale, e.g. "fr".
|
||||
* @param string $countryCode Country code, in ISO 3166-1 alpha-2 format, e.g. "FR"
|
||||
* @param string $encoding Encoding of the final locale
|
||||
* @param string $expected Expected long form of the locale
|
||||
*
|
||||
* @dataProvider provideLanguageEncodingAndCountryCode
|
||||
*/
|
||||
public function testGetLongForm($languageCode, $countryCode, $encoding, $expected)
|
||||
{
|
||||
self::assertEquals($expected, Locale::getLongForm($languageCode, $countryCode, $encoding));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $emptyValue Empty value, e.g. ""
|
||||
* @dataProvider provideEmptyValue
|
||||
*/
|
||||
public function testSetLocaleEmptyCategoryAndLanguageCode($emptyValue)
|
||||
{
|
||||
self::assertFalse(Locale::setLocale($emptyValue, $emptyValue));
|
||||
}
|
||||
|
||||
public function testSetLocaleIncorrectCategory()
|
||||
{
|
||||
self::assertFalse(Locale::setLocale(-1, 'en'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $category Named constant specifying the category of the functions affected by the locale
|
||||
* setting. It's the same constant as required by setlocale() function.
|
||||
* @param string $languageCode Language code, in ISO 639-1 format. Short form of the locale, e.g. "fr".
|
||||
* @param string $countryCode Country code, in ISO 3166-1 alpha-2 format, e.g. "FR"
|
||||
* @param string $expectedLocale Expected locale
|
||||
*
|
||||
* @dataProvider provideCategoryLanguageCodeAndExpectedLocale
|
||||
*/
|
||||
public function testSetLocale($category, $languageCode, $countryCode, $expectedLocale)
|
||||
{
|
||||
self::assertEquals($expectedLocale, Locale::setLocale($category, $languageCode, $countryCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $category Named constant specifying the category of the functions affected by the locale
|
||||
* setting. It's the same constant as required by setlocale() function.
|
||||
@@ -98,130 +176,52 @@ class LocaleTest extends BaseTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides language, encoding and country code
|
||||
* @param string $languageCode Language code, in ISO 639-1 format. Short form of the locale, e.g. "fr".
|
||||
* @param string $countryCode Country code, in ISO 3166-1 alpha-2 format, e.g. "FR"
|
||||
* @param string $encoding Encoding of the final locale
|
||||
* @param string $expected Expected long form of the locale
|
||||
*
|
||||
* @return Generator
|
||||
* @dataProvider provideLanguageEncodingAndCountryCode
|
||||
*/
|
||||
public function provideLanguageEncodingAndCountryCode()
|
||||
public function testGetLongForm($languageCode, $countryCode, $encoding, $expected)
|
||||
{
|
||||
yield[
|
||||
'fr',
|
||||
'',
|
||||
'',
|
||||
'fr_FR',
|
||||
];
|
||||
|
||||
yield[
|
||||
'fr',
|
||||
'',
|
||||
'UTF-8',
|
||||
'fr_FR.UTF-8',
|
||||
];
|
||||
|
||||
yield[
|
||||
'fr',
|
||||
'FR',
|
||||
'',
|
||||
'fr_FR',
|
||||
];
|
||||
|
||||
yield[
|
||||
'fr',
|
||||
'FR',
|
||||
'UTF-8',
|
||||
'fr_FR.UTF-8',
|
||||
];
|
||||
|
||||
yield[
|
||||
'en',
|
||||
'US',
|
||||
'',
|
||||
'en_US',
|
||||
];
|
||||
|
||||
yield[
|
||||
'en',
|
||||
'US',
|
||||
'UTF-8',
|
||||
'en_US.UTF-8',
|
||||
];
|
||||
|
||||
yield[
|
||||
'en',
|
||||
'US',
|
||||
'ISO-8859-1',
|
||||
'en_US.ISO-8859-1',
|
||||
];
|
||||
self::assertEquals($expected, Locale::getLongForm($languageCode, $countryCode, $encoding));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides category
|
||||
*
|
||||
* @return Generator
|
||||
* @param mixed $languageCode Empty value, e.g. ""
|
||||
* @dataProvider provideEmptyValue
|
||||
*/
|
||||
public function provideCategoryLanguageCodeAndExpectedLocale()
|
||||
public function testGetLongFormEmptyLanguageCode($languageCode)
|
||||
{
|
||||
yield[
|
||||
LC_ALL,
|
||||
'fr',
|
||||
'',
|
||||
'fr_FR.UTF-8',
|
||||
];
|
||||
self::assertEquals('', Locale::getLongForm($languageCode));
|
||||
}
|
||||
|
||||
yield[
|
||||
LC_COLLATE,
|
||||
'fr',
|
||||
'FR',
|
||||
'fr_FR.UTF-8',
|
||||
];
|
||||
/**
|
||||
* @param int $category Named constant specifying the category of the functions affected by the locale
|
||||
* setting. It's the same constant as required by setlocale() function.
|
||||
* @param string $languageCode Language code, in ISO 639-1 format. Short form of the locale, e.g. "fr".
|
||||
* @param string $countryCode Country code, in ISO 3166-1 alpha-2 format, e.g. "FR"
|
||||
* @param string $expectedLocale Expected locale
|
||||
*
|
||||
* @dataProvider provideCategoryLanguageCodeAndExpectedLocale
|
||||
*/
|
||||
public function testSetLocale($category, $languageCode, $countryCode, $expectedLocale)
|
||||
{
|
||||
self::assertEquals($expectedLocale, Locale::setLocale($category, $languageCode, $countryCode));
|
||||
}
|
||||
|
||||
yield[
|
||||
LC_CTYPE,
|
||||
'en',
|
||||
'US',
|
||||
'en_US.UTF-8',
|
||||
];
|
||||
/**
|
||||
* @param mixed $emptyValue Empty value, e.g. ""
|
||||
* @dataProvider provideEmptyValue
|
||||
*/
|
||||
public function testSetLocaleEmptyCategoryAndLanguageCode($emptyValue)
|
||||
{
|
||||
self::assertFalse(Locale::setLocale($emptyValue, $emptyValue));
|
||||
}
|
||||
|
||||
yield[
|
||||
LC_NUMERIC,
|
||||
'en',
|
||||
'GB',
|
||||
'en_GB.UTF-8',
|
||||
];
|
||||
|
||||
yield[
|
||||
LC_MONETARY,
|
||||
'es',
|
||||
'',
|
||||
'es_ES.UTF-8',
|
||||
];
|
||||
|
||||
yield[
|
||||
LC_MONETARY,
|
||||
'es',
|
||||
'ES',
|
||||
'es_ES.UTF-8',
|
||||
];
|
||||
|
||||
yield[
|
||||
LC_TIME,
|
||||
'it',
|
||||
'',
|
||||
'it_IT.UTF-8',
|
||||
];
|
||||
|
||||
yield[
|
||||
LC_TIME,
|
||||
'it',
|
||||
'IT',
|
||||
'it_IT.UTF-8',
|
||||
];
|
||||
|
||||
yield[
|
||||
LC_TIME,
|
||||
'it',
|
||||
'it',
|
||||
'it_IT.UTF-8',
|
||||
];
|
||||
public function testSetLocaleIncorrectCategory()
|
||||
{
|
||||
self::assertFalse(Locale::setLocale(-1, 'en'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,15 +19,309 @@ use Meritoo\Common\Utilities\MimeTypes;
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\MimeTypes
|
||||
* @covers \Meritoo\Common\Utilities\MimeTypes
|
||||
*/
|
||||
class MimeTypesTest extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* Provides real file path to get information if the file is an image
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideExistingFilePathToCheckIsImagePath()
|
||||
{
|
||||
yield [
|
||||
$this->getFilePathForTesting('minion.jpg'),
|
||||
true,
|
||||
];
|
||||
|
||||
yield [
|
||||
$this->getFilePathForTesting('lorem-ipsum.txt'),
|
||||
false,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides real file path to get mime type
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideFilePathToGetMimeTypeOfRealFile()
|
||||
{
|
||||
yield [
|
||||
$this->getFilePathForTesting('minion.jpg'),
|
||||
'image/jpeg',
|
||||
];
|
||||
|
||||
yield [
|
||||
$this->getFilePathForTesting('lorem-ipsum.txt'),
|
||||
'text/plain',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides mime type of image
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideImageMimeType()
|
||||
{
|
||||
yield ['image/bmp'];
|
||||
yield ['image/jpeg'];
|
||||
yield ['image/png'];
|
||||
yield ['image/tiff'];
|
||||
yield ['image/vnd.microsoft.icon'];
|
||||
yield ['image/x-rgb'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides existing mime type used to get multiple, more than one extension
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideMimeTypeToGetMultipleExtension()
|
||||
{
|
||||
yield [
|
||||
'application/postscript',
|
||||
[
|
||||
'ai',
|
||||
'eps',
|
||||
'ps',
|
||||
],
|
||||
];
|
||||
|
||||
yield [
|
||||
'audio/midi',
|
||||
[
|
||||
'mid',
|
||||
'midi',
|
||||
'kar',
|
||||
'rmi',
|
||||
],
|
||||
];
|
||||
|
||||
yield [
|
||||
'image/jpeg',
|
||||
[
|
||||
'jpeg',
|
||||
'jpe',
|
||||
'jpg',
|
||||
],
|
||||
];
|
||||
|
||||
yield [
|
||||
'text/html',
|
||||
[
|
||||
'html',
|
||||
'htm',
|
||||
],
|
||||
];
|
||||
|
||||
yield [
|
||||
'text/plain',
|
||||
[
|
||||
'txt',
|
||||
'text',
|
||||
'conf',
|
||||
'def',
|
||||
'list',
|
||||
'log',
|
||||
'in',
|
||||
],
|
||||
];
|
||||
|
||||
yield [
|
||||
'video/mp4',
|
||||
[
|
||||
'mp4',
|
||||
'mp4v',
|
||||
'mpg4',
|
||||
'm4v',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides existing mime type used to get single, one extension
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideMimeTypeToGetSingleExtension()
|
||||
{
|
||||
yield [
|
||||
'application/x-7z-compressed',
|
||||
'7z',
|
||||
];
|
||||
|
||||
yield [
|
||||
'application/json',
|
||||
'json',
|
||||
];
|
||||
|
||||
yield [
|
||||
'application/zip',
|
||||
'zip',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides mime types used to get extensions
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideMimesTypesToGetExtensions()
|
||||
{
|
||||
yield [
|
||||
[
|
||||
'application/x-7z-compressed',
|
||||
'application/json',
|
||||
],
|
||||
[
|
||||
'application/x-7z-compressed' => '7z',
|
||||
'application/json' => 'json',
|
||||
],
|
||||
];
|
||||
|
||||
yield [
|
||||
[
|
||||
'application/mathematica',
|
||||
'application/xml',
|
||||
'audio/mp4',
|
||||
'video/mp4',
|
||||
],
|
||||
[
|
||||
'application/mathematica' => [
|
||||
'ma',
|
||||
'nb',
|
||||
'mb',
|
||||
],
|
||||
'application/xml' => [
|
||||
'xml',
|
||||
'xsl',
|
||||
],
|
||||
'audio/mp4' => 'mp4a',
|
||||
'video/mp4' => [
|
||||
'mp4',
|
||||
'mp4v',
|
||||
'mpg4',
|
||||
'm4v',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides mime types used to get extensions as upper case
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideMimesTypesToGetExtensionsUpperCase()
|
||||
{
|
||||
yield [
|
||||
[
|
||||
'application/x-7z-compressed',
|
||||
'application/json',
|
||||
],
|
||||
[
|
||||
'application/x-7z-compressed' => '7Z',
|
||||
'application/json' => 'JSON',
|
||||
],
|
||||
];
|
||||
|
||||
yield [
|
||||
[
|
||||
'application/xml',
|
||||
'audio/mp4',
|
||||
'text/html',
|
||||
'video/mp4',
|
||||
],
|
||||
[
|
||||
'application/xml' => [
|
||||
'XML',
|
||||
'XSL',
|
||||
],
|
||||
'audio/mp4' => 'MP4A',
|
||||
'text/html' => [
|
||||
'HTML',
|
||||
'HTM',
|
||||
],
|
||||
'video/mp4' => [
|
||||
'MP4',
|
||||
'MP4V',
|
||||
'MPG4',
|
||||
'M4V',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides mime type of non-image
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideNonImageMimeType()
|
||||
{
|
||||
yield ['application/rtf'];
|
||||
yield ['audio/mp4'];
|
||||
yield ['text/plain'];
|
||||
yield ['text/html'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides not existing mime type
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideNotExistingMimeType()
|
||||
{
|
||||
yield ['lorem/ipsum'];
|
||||
yield ['dolor'];
|
||||
yield ['x/y/z'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides not existing mime types
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideNotExistingMimeTypes()
|
||||
{
|
||||
yield [
|
||||
[],
|
||||
];
|
||||
|
||||
yield [
|
||||
[
|
||||
'',
|
||||
null,
|
||||
false,
|
||||
0,
|
||||
],
|
||||
];
|
||||
|
||||
yield [
|
||||
[
|
||||
'lorem/ipsum',
|
||||
'dolor/sit',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(MimeTypes::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $mimeType The mime type, e.g. "video/mpeg"
|
||||
* @dataProvider provideBooleanValue
|
||||
*/
|
||||
public function testGetExtensionBooleanMimeType($mimeType)
|
||||
{
|
||||
self::assertEquals('', MimeTypes::getExtension($mimeType));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mimeType Empty value, e.g. ""
|
||||
* @dataProvider provideEmptyValue
|
||||
@@ -38,12 +332,14 @@ class MimeTypesTest extends BaseTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $mimeType The mime type, e.g. "video/mpeg"
|
||||
* @dataProvider provideBooleanValue
|
||||
* @param string $mimeType The mime type, e.g. "video/mpeg"
|
||||
* @param array $extensions Expected extensions
|
||||
*
|
||||
* @dataProvider provideMimeTypeToGetMultipleExtension
|
||||
*/
|
||||
public function testGetExtensionBooleanMimeType($mimeType)
|
||||
public function testGetExtensionMultiple($mimeType, $extensions)
|
||||
{
|
||||
self::assertEquals('', MimeTypes::getExtension($mimeType));
|
||||
self::assertEquals($extensions, MimeTypes::getExtension($mimeType));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,14 +363,14 @@ class MimeTypesTest extends BaseTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $mimeType The mime type, e.g. "video/mpeg"
|
||||
* @param array $extensions Expected extensions
|
||||
* @param array $mimesTypes The mimes types, e.g. ['video/mpeg', 'image/jpeg']
|
||||
* @param array $extensions Expected extensions
|
||||
*
|
||||
* @dataProvider provideMimeTypeToGetMultipleExtension
|
||||
* @dataProvider provideMimesTypesToGetExtensions
|
||||
*/
|
||||
public function testGetExtensionMultiple($mimeType, $extensions)
|
||||
public function testGetExtensions($mimesTypes, $extensions)
|
||||
{
|
||||
self::assertEquals($extensions, MimeTypes::getExtension($mimeType));
|
||||
self::assertEquals($extensions, MimeTypes::getExtensions($mimesTypes));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,17 +382,6 @@ class MimeTypesTest extends BaseTestCase
|
||||
self::assertEquals([], MimeTypes::getExtensions($mimesTypes));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $mimesTypes The mimes types, e.g. ['video/mpeg', 'image/jpeg']
|
||||
* @param array $extensions Expected extensions
|
||||
*
|
||||
* @dataProvider provideMimesTypesToGetExtensions
|
||||
*/
|
||||
public function testGetExtensions($mimesTypes, $extensions)
|
||||
{
|
||||
self::assertEquals($extensions, MimeTypes::getExtensions($mimesTypes));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $mimesTypes The mimes types, e.g. ['video/mpeg', 'image/jpeg']
|
||||
* @param array $extensions Expected extensions
|
||||
@@ -138,12 +423,12 @@ class MimeTypesTest extends BaseTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $mimeType Not existing mime type, e.g. "lorem/ipsum"
|
||||
* @dataProvider provideNotExistingMimeType
|
||||
* @param string $mimeType Mime type of image, e.g. "image/jpeg"
|
||||
* @dataProvider provideImageMimeType
|
||||
*/
|
||||
public function testIsImageNotExistingMimeType($mimeType)
|
||||
public function testIsImageImageMimeType($mimeType)
|
||||
{
|
||||
self::assertFalse(MimeTypes::isImage($mimeType));
|
||||
self::assertTrue(MimeTypes::isImage($mimeType));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,6 +440,15 @@ class MimeTypesTest extends BaseTestCase
|
||||
self::assertFalse(MimeTypes::isImage($mimeType));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $mimeType Not existing mime type, e.g. "lorem/ipsum"
|
||||
* @dataProvider provideNotExistingMimeType
|
||||
*/
|
||||
public function testIsImageNotExistingMimeType($mimeType)
|
||||
{
|
||||
self::assertFalse(MimeTypes::isImage($mimeType));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $path Empty value, e.g. ""
|
||||
* @dataProvider provideEmptyValue
|
||||
@@ -164,15 +458,6 @@ class MimeTypesTest extends BaseTestCase
|
||||
self::assertFalse(MimeTypes::isImagePath($path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $path Path of not existing file, e.g. "lorem/ipsum.jpg"
|
||||
* @dataProvider provideNotExistingFilePath
|
||||
*/
|
||||
public function testIsImagePathNotExistingPath($path)
|
||||
{
|
||||
self::assertFalse(MimeTypes::isImagePath($path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path Path of the file to check
|
||||
* @param bool $isImage Expected information if the file is an image
|
||||
@@ -185,296 +470,11 @@ class MimeTypesTest extends BaseTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $mimeType Mime type of image, e.g. "image/jpeg"
|
||||
* @dataProvider provideImageMimeType
|
||||
* @param mixed $path Path of not existing file, e.g. "lorem/ipsum.jpg"
|
||||
* @dataProvider provideNotExistingFilePath
|
||||
*/
|
||||
public function testIsImageImageMimeType($mimeType)
|
||||
public function testIsImagePathNotExistingPath($path)
|
||||
{
|
||||
self::assertTrue(MimeTypes::isImage($mimeType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides not existing mime type
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideNotExistingMimeType()
|
||||
{
|
||||
yield['lorem/ipsum'];
|
||||
yield['dolor'];
|
||||
yield['x/y/z'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides mime type of non-image
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideNonImageMimeType()
|
||||
{
|
||||
yield['application/rtf'];
|
||||
yield['audio/mp4'];
|
||||
yield['text/plain'];
|
||||
yield['text/html'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides mime type of image
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideImageMimeType()
|
||||
{
|
||||
yield['image/bmp'];
|
||||
yield['image/jpeg'];
|
||||
yield['image/png'];
|
||||
yield['image/tiff'];
|
||||
yield['image/vnd.microsoft.icon'];
|
||||
yield['image/x-rgb'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides existing mime type used to get single, one extension
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideMimeTypeToGetSingleExtension()
|
||||
{
|
||||
yield[
|
||||
'application/x-7z-compressed',
|
||||
'7z',
|
||||
];
|
||||
|
||||
yield[
|
||||
'application/json',
|
||||
'json',
|
||||
];
|
||||
|
||||
yield[
|
||||
'application/zip',
|
||||
'zip',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides existing mime type used to get multiple, more than one extension
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideMimeTypeToGetMultipleExtension()
|
||||
{
|
||||
yield[
|
||||
'application/postscript',
|
||||
[
|
||||
'ai',
|
||||
'eps',
|
||||
'ps',
|
||||
],
|
||||
];
|
||||
|
||||
yield[
|
||||
'audio/midi',
|
||||
[
|
||||
'mid',
|
||||
'midi',
|
||||
'kar',
|
||||
'rmi',
|
||||
],
|
||||
];
|
||||
|
||||
yield[
|
||||
'image/jpeg',
|
||||
[
|
||||
'jpeg',
|
||||
'jpe',
|
||||
'jpg',
|
||||
],
|
||||
];
|
||||
|
||||
yield[
|
||||
'text/html',
|
||||
[
|
||||
'html',
|
||||
'htm',
|
||||
],
|
||||
];
|
||||
|
||||
yield[
|
||||
'text/plain',
|
||||
[
|
||||
'txt',
|
||||
'text',
|
||||
'conf',
|
||||
'def',
|
||||
'list',
|
||||
'log',
|
||||
'in',
|
||||
],
|
||||
];
|
||||
|
||||
yield[
|
||||
'video/mp4',
|
||||
[
|
||||
'mp4',
|
||||
'mp4v',
|
||||
'mpg4',
|
||||
'm4v',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides not existing mime types
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideNotExistingMimeTypes()
|
||||
{
|
||||
yield[
|
||||
[],
|
||||
];
|
||||
|
||||
yield[
|
||||
[
|
||||
'',
|
||||
null,
|
||||
false,
|
||||
0,
|
||||
],
|
||||
];
|
||||
|
||||
yield[
|
||||
[
|
||||
'lorem/ipsum',
|
||||
'dolor/sit',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides mime types used to get extensions
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideMimesTypesToGetExtensions()
|
||||
{
|
||||
yield[
|
||||
[
|
||||
'application/x-7z-compressed',
|
||||
'application/json',
|
||||
],
|
||||
[
|
||||
'application/x-7z-compressed' => '7z',
|
||||
'application/json' => 'json',
|
||||
],
|
||||
];
|
||||
|
||||
yield[
|
||||
[
|
||||
'application/mathematica',
|
||||
'application/xml',
|
||||
'audio/mp4',
|
||||
'video/mp4',
|
||||
],
|
||||
[
|
||||
'application/mathematica' => [
|
||||
'ma',
|
||||
'nb',
|
||||
'mb',
|
||||
],
|
||||
'application/xml' => [
|
||||
'xml',
|
||||
'xsl',
|
||||
],
|
||||
'audio/mp4' => 'mp4a',
|
||||
'video/mp4' => [
|
||||
'mp4',
|
||||
'mp4v',
|
||||
'mpg4',
|
||||
'm4v',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides mime types used to get extensions as upper case
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideMimesTypesToGetExtensionsUpperCase()
|
||||
{
|
||||
yield[
|
||||
[
|
||||
'application/x-7z-compressed',
|
||||
'application/json',
|
||||
],
|
||||
[
|
||||
'application/x-7z-compressed' => '7Z',
|
||||
'application/json' => 'JSON',
|
||||
],
|
||||
];
|
||||
|
||||
yield[
|
||||
[
|
||||
'application/xml',
|
||||
'audio/mp4',
|
||||
'text/html',
|
||||
'video/mp4',
|
||||
],
|
||||
[
|
||||
'application/xml' => [
|
||||
'XML',
|
||||
'XSL',
|
||||
],
|
||||
'audio/mp4' => 'MP4A',
|
||||
'text/html' => [
|
||||
'HTML',
|
||||
'HTM',
|
||||
],
|
||||
'video/mp4' => [
|
||||
'MP4',
|
||||
'MP4V',
|
||||
'MPG4',
|
||||
'M4V',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides real file path to get mime type
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideFilePathToGetMimeTypeOfRealFile()
|
||||
{
|
||||
yield[
|
||||
$this->getFilePathForTesting('minion.jpg'),
|
||||
'image/jpeg',
|
||||
];
|
||||
|
||||
yield[
|
||||
$this->getFilePathForTesting('lorem-ipsum.txt'),
|
||||
'text/plain',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides real file path to get information if the file is an image
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideExistingFilePathToCheckIsImagePath()
|
||||
{
|
||||
yield[
|
||||
$this->getFilePathForTesting('minion.jpg'),
|
||||
true,
|
||||
];
|
||||
|
||||
yield[
|
||||
$this->getFilePathForTesting('lorem-ipsum.txt'),
|
||||
false,
|
||||
];
|
||||
self::assertFalse(MimeTypes::isImagePath($path));
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,7 @@ use Doctrine\ORM\QueryBuilder;
|
||||
use Generator;
|
||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||
use Meritoo\Common\Utilities\QueryBuilderUtility;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Test case of the useful methods for query builder (the Doctrine's QueryBuilder class)
|
||||
@@ -25,24 +26,260 @@ use Meritoo\Common\Utilities\QueryBuilderUtility;
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\QueryBuilderUtility
|
||||
* @covers \Meritoo\Common\Utilities\QueryBuilderUtility
|
||||
*/
|
||||
class QueryBuilderUtilityTest extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* Provides query builder and criteria used in WHERE clause
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideQueryBuilderAndCriteria()
|
||||
{
|
||||
$entityManager = $this
|
||||
->getMockBuilder(EntityManager::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getExpressionBuilder'])
|
||||
->getMock();
|
||||
|
||||
$entityManager
|
||||
->expects(static::any())
|
||||
->method('getExpressionBuilder')
|
||||
->willReturn(new Expr())
|
||||
;
|
||||
|
||||
yield [
|
||||
(new QueryBuilder($entityManager))->from('lorem_ipsum', 'lm'),
|
||||
[
|
||||
'lorem' => 11,
|
||||
'ipsum' => 22,
|
||||
'dolor' => null,
|
||||
],
|
||||
];
|
||||
|
||||
yield [
|
||||
(new QueryBuilder($entityManager))->from('lorem_ipsum', 'lm'),
|
||||
[
|
||||
'lorem' => [
|
||||
11,
|
||||
'>=',
|
||||
],
|
||||
'ipsum' => [
|
||||
22,
|
||||
'<',
|
||||
],
|
||||
'dolor' => null,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides query builder and parameters to add to given query builder
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideQueryBuilderAndParameters()
|
||||
{
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
|
||||
yield [
|
||||
new QueryBuilder($entityManager),
|
||||
[],
|
||||
];
|
||||
|
||||
yield [
|
||||
new QueryBuilder($entityManager),
|
||||
new ArrayCollection(),
|
||||
];
|
||||
|
||||
yield [
|
||||
new QueryBuilder($entityManager),
|
||||
[
|
||||
'lorem' => 11,
|
||||
'ipsum' => 22,
|
||||
],
|
||||
];
|
||||
|
||||
yield [
|
||||
new QueryBuilder($entityManager),
|
||||
new ArrayCollection([
|
||||
'lorem' => 11,
|
||||
'ipsum' => 22,
|
||||
]),
|
||||
];
|
||||
|
||||
yield [
|
||||
new QueryBuilder($entityManager),
|
||||
[
|
||||
new Parameter('lorem', 11),
|
||||
new Parameter('ipsum', 22),
|
||||
],
|
||||
];
|
||||
|
||||
yield [
|
||||
new QueryBuilder($entityManager),
|
||||
new ArrayCollection([
|
||||
new Parameter('lorem', 11),
|
||||
new Parameter('ipsum', 22),
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides query builder, name of property and expected alias of given property
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideQueryBuilderAndPropertyAlias()
|
||||
{
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
|
||||
yield [
|
||||
new QueryBuilder($entityManager),
|
||||
'',
|
||||
null,
|
||||
];
|
||||
|
||||
yield [
|
||||
new QueryBuilder($entityManager),
|
||||
'lorem',
|
||||
null,
|
||||
];
|
||||
|
||||
yield [
|
||||
(new QueryBuilder($entityManager))->from('lorem_ipsum', 'lm'),
|
||||
'lm',
|
||||
null,
|
||||
];
|
||||
|
||||
yield [
|
||||
(new QueryBuilder($entityManager))
|
||||
->from('lorem', 'l')
|
||||
->leftJoin('l.ipsum', 'i'),
|
||||
'ipsum',
|
||||
'i',
|
||||
];
|
||||
|
||||
yield [
|
||||
(new QueryBuilder($entityManager))
|
||||
->from('lorem', 'l')
|
||||
->leftJoin('l.ipsum', 'i')
|
||||
->innerJoin('i.dolor', 'd'),
|
||||
'ipsum1',
|
||||
null,
|
||||
];
|
||||
|
||||
yield [
|
||||
(new QueryBuilder($entityManager))
|
||||
->from('lorem', 'l')
|
||||
->leftJoin('l.ipsum', 'i')
|
||||
->innerJoin('i.dolor', 'd'),
|
||||
'ipsum',
|
||||
'i',
|
||||
];
|
||||
|
||||
yield [
|
||||
(new QueryBuilder($entityManager))
|
||||
->from('lorem', 'l')
|
||||
->leftJoin('l.ipsum', 'i')
|
||||
->innerJoin('i.dolor', 'd'),
|
||||
'dolor',
|
||||
'd',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides query builder to retrieve root alias and expected root alias
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideQueryBuilderAndRootAlias()
|
||||
{
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
|
||||
yield [
|
||||
new QueryBuilder($entityManager),
|
||||
null,
|
||||
];
|
||||
|
||||
yield [
|
||||
(new QueryBuilder($entityManager))->from('lorem_ipsum', 'lm'),
|
||||
'lm',
|
||||
];
|
||||
|
||||
yield [
|
||||
(new QueryBuilder($entityManager))
|
||||
->from('lorem', 'l')
|
||||
->leftJoin('l.ipsum', 'i'),
|
||||
'l',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param QueryBuilder $queryBuilder The query builder
|
||||
* @param array|ArrayCollection $parameters Parameters to add. Collection of Doctrine\ORM\Query\Parameter
|
||||
* instances or an array with key-value pairs.
|
||||
*
|
||||
* @dataProvider provideQueryBuilderAndParameters
|
||||
*/
|
||||
public function testAddParameters(QueryBuilder $queryBuilder, $parameters)
|
||||
{
|
||||
$newQueryBuilder = QueryBuilderUtility::addParameters($queryBuilder, $parameters);
|
||||
|
||||
static::assertSame($queryBuilder, $newQueryBuilder);
|
||||
static::assertCount(count($parameters), $newQueryBuilder->getParameters());
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(QueryBuilderUtility::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param QueryBuilder $queryBuilder The query builder to retrieve root alias
|
||||
* @param null|string $rootAlias Expected root alias of given query builder
|
||||
*
|
||||
* @dataProvider provideQueryBuilderAndRootAlias
|
||||
*/
|
||||
public function testGetRootAlias(QueryBuilder $queryBuilder, $rootAlias)
|
||||
public function testDeleteEntities()
|
||||
{
|
||||
static::assertSame($rootAlias, QueryBuilderUtility::getRootAlias($queryBuilder));
|
||||
$methods = [
|
||||
'remove',
|
||||
'flush',
|
||||
];
|
||||
|
||||
$entityManager = $this
|
||||
->getMockBuilder(EntityManager::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods($methods)
|
||||
->getMock();
|
||||
|
||||
$entities1 = [];
|
||||
|
||||
$entities2 = [
|
||||
new stdClass(),
|
||||
];
|
||||
|
||||
static::assertFalse(QueryBuilderUtility::deleteEntities($entityManager, $entities1));
|
||||
static::assertTrue(QueryBuilderUtility::deleteEntities($entityManager, $entities2));
|
||||
}
|
||||
|
||||
public function testDeleteEntitiesWithoutFlush()
|
||||
{
|
||||
$methods = [
|
||||
'remove',
|
||||
'flush',
|
||||
];
|
||||
|
||||
$entityManager = $this
|
||||
->getMockBuilder(EntityManager::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods($methods)
|
||||
->getMock();
|
||||
|
||||
$entities1 = [];
|
||||
|
||||
$entities2 = [
|
||||
new stdClass(),
|
||||
];
|
||||
|
||||
static::assertFalse(QueryBuilderUtility::deleteEntities($entityManager, $entities1, false));
|
||||
static::assertTrue(QueryBuilderUtility::deleteEntities($entityManager, $entities2, false));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,31 +294,15 @@ class QueryBuilderUtilityTest extends BaseTestCase
|
||||
static::assertSame($propertyAlias, QueryBuilderUtility::getJoinedPropertyAlias($queryBuilder, $propertyName));
|
||||
}
|
||||
|
||||
public function testSetCriteriaWithoutCriteria()
|
||||
/**
|
||||
* @param QueryBuilder $queryBuilder The query builder to retrieve root alias
|
||||
* @param null|string $rootAlias Expected root alias of given query builder
|
||||
*
|
||||
* @dataProvider provideQueryBuilderAndRootAlias
|
||||
*/
|
||||
public function testGetRootAlias(QueryBuilder $queryBuilder, $rootAlias)
|
||||
{
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$queryBuilder = new QueryBuilder($entityManager);
|
||||
$newQueryBuilder = QueryBuilderUtility::setCriteria($queryBuilder);
|
||||
|
||||
static::assertSame($queryBuilder, $newQueryBuilder);
|
||||
static::assertCount(0, $newQueryBuilder->getParameters());
|
||||
static::assertNull($newQueryBuilder->getDQLPart('where'));
|
||||
}
|
||||
|
||||
public function testSetCriteriaWithoutAlias()
|
||||
{
|
||||
$criteria = [
|
||||
'lorem' => 11,
|
||||
'ipsum' => 22,
|
||||
];
|
||||
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$queryBuilder = new QueryBuilder($entityManager);
|
||||
$newQueryBuilder = QueryBuilderUtility::setCriteria($queryBuilder, $criteria);
|
||||
|
||||
static::assertSame($queryBuilder, $newQueryBuilder);
|
||||
static::assertCount(count($criteria), $newQueryBuilder->getParameters());
|
||||
static::assertNotNull($newQueryBuilder->getDQLPart('where'));
|
||||
static::assertSame($rootAlias, QueryBuilderUtility::getRootAlias($queryBuilder));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,253 +329,30 @@ class QueryBuilderUtilityTest extends BaseTestCase
|
||||
static::assertNotNull($newQueryBuilder->getDQLPart('where'));
|
||||
}
|
||||
|
||||
public function testDeleteEntitiesWithoutFlush()
|
||||
public function testSetCriteriaWithoutAlias()
|
||||
{
|
||||
$methods = [
|
||||
'remove',
|
||||
'flush',
|
||||
$criteria = [
|
||||
'lorem' => 11,
|
||||
'ipsum' => 22,
|
||||
];
|
||||
|
||||
$entityManager = $this
|
||||
->getMockBuilder(EntityManager::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods($methods)
|
||||
->getMock()
|
||||
;
|
||||
|
||||
$entities1 = [];
|
||||
|
||||
$entities2 = [
|
||||
new \stdClass(),
|
||||
];
|
||||
|
||||
static::assertFalse(QueryBuilderUtility::deleteEntities($entityManager, $entities1, false));
|
||||
static::assertTrue(QueryBuilderUtility::deleteEntities($entityManager, $entities2, false));
|
||||
}
|
||||
|
||||
public function testDeleteEntities()
|
||||
{
|
||||
$methods = [
|
||||
'remove',
|
||||
'flush',
|
||||
];
|
||||
|
||||
$entityManager = $this
|
||||
->getMockBuilder(EntityManager::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods($methods)
|
||||
->getMock()
|
||||
;
|
||||
|
||||
$entities1 = [];
|
||||
|
||||
$entities2 = [
|
||||
new \stdClass(),
|
||||
];
|
||||
|
||||
static::assertFalse(QueryBuilderUtility::deleteEntities($entityManager, $entities1));
|
||||
static::assertTrue(QueryBuilderUtility::deleteEntities($entityManager, $entities2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param QueryBuilder $queryBuilder The query builder
|
||||
* @param array|ArrayCollection $parameters Parameters to add. Collection of Doctrine\ORM\Query\Parameter
|
||||
* instances or an array with key-value pairs.
|
||||
*
|
||||
* @dataProvider provideQueryBuilderAndParameters
|
||||
*/
|
||||
public function testAddParameters(QueryBuilder $queryBuilder, $parameters)
|
||||
{
|
||||
$newQueryBuilder = QueryBuilderUtility::addParameters($queryBuilder, $parameters);
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$queryBuilder = new QueryBuilder($entityManager);
|
||||
$newQueryBuilder = QueryBuilderUtility::setCriteria($queryBuilder, $criteria);
|
||||
|
||||
static::assertSame($queryBuilder, $newQueryBuilder);
|
||||
static::assertCount(count($parameters), $newQueryBuilder->getParameters());
|
||||
static::assertCount(count($criteria), $newQueryBuilder->getParameters());
|
||||
static::assertNotNull($newQueryBuilder->getDQLPart('where'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides query builder to retrieve root alias and expected root alias
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideQueryBuilderAndRootAlias()
|
||||
public function testSetCriteriaWithoutCriteria()
|
||||
{
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$queryBuilder = new QueryBuilder($entityManager);
|
||||
$newQueryBuilder = QueryBuilderUtility::setCriteria($queryBuilder);
|
||||
|
||||
yield[
|
||||
new QueryBuilder($entityManager),
|
||||
null,
|
||||
];
|
||||
|
||||
yield[
|
||||
(new QueryBuilder($entityManager))->from('lorem_ipsum', 'lm'),
|
||||
'lm',
|
||||
];
|
||||
|
||||
yield[
|
||||
(new QueryBuilder($entityManager))
|
||||
->from('lorem', 'l')
|
||||
->leftJoin('l.ipsum', 'i'),
|
||||
'l',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides query builder, name of property and expected alias of given property
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideQueryBuilderAndPropertyAlias()
|
||||
{
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
|
||||
yield[
|
||||
new QueryBuilder($entityManager),
|
||||
'',
|
||||
null,
|
||||
];
|
||||
|
||||
yield[
|
||||
new QueryBuilder($entityManager),
|
||||
'lorem',
|
||||
null,
|
||||
];
|
||||
|
||||
yield[
|
||||
(new QueryBuilder($entityManager))->from('lorem_ipsum', 'lm'),
|
||||
'lm',
|
||||
null,
|
||||
];
|
||||
|
||||
yield[
|
||||
(new QueryBuilder($entityManager))
|
||||
->from('lorem', 'l')
|
||||
->leftJoin('l.ipsum', 'i'),
|
||||
'ipsum',
|
||||
'i',
|
||||
];
|
||||
|
||||
yield[
|
||||
(new QueryBuilder($entityManager))
|
||||
->from('lorem', 'l')
|
||||
->leftJoin('l.ipsum', 'i')
|
||||
->innerJoin('i.dolor', 'd'),
|
||||
'ipsum1',
|
||||
null,
|
||||
];
|
||||
|
||||
yield[
|
||||
(new QueryBuilder($entityManager))
|
||||
->from('lorem', 'l')
|
||||
->leftJoin('l.ipsum', 'i')
|
||||
->innerJoin('i.dolor', 'd'),
|
||||
'ipsum',
|
||||
'i',
|
||||
];
|
||||
|
||||
yield[
|
||||
(new QueryBuilder($entityManager))
|
||||
->from('lorem', 'l')
|
||||
->leftJoin('l.ipsum', 'i')
|
||||
->innerJoin('i.dolor', 'd'),
|
||||
'dolor',
|
||||
'd',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides query builder and criteria used in WHERE clause
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideQueryBuilderAndCriteria()
|
||||
{
|
||||
$entityManager = $this
|
||||
->getMockBuilder(EntityManager::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getExpressionBuilder'])
|
||||
->getMock()
|
||||
;
|
||||
|
||||
$entityManager
|
||||
->expects(static::any())
|
||||
->method('getExpressionBuilder')
|
||||
->willReturn(new Expr())
|
||||
;
|
||||
|
||||
yield[
|
||||
(new QueryBuilder($entityManager))->from('lorem_ipsum', 'lm'),
|
||||
[
|
||||
'lorem' => 11,
|
||||
'ipsum' => 22,
|
||||
'dolor' => null,
|
||||
],
|
||||
];
|
||||
|
||||
yield[
|
||||
(new QueryBuilder($entityManager))->from('lorem_ipsum', 'lm'),
|
||||
[
|
||||
'lorem' => [
|
||||
11,
|
||||
'>=',
|
||||
],
|
||||
'ipsum' => [
|
||||
22,
|
||||
'<',
|
||||
],
|
||||
'dolor' => null,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides query builder and parameters to add to given query builder
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideQueryBuilderAndParameters()
|
||||
{
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
|
||||
yield[
|
||||
new QueryBuilder($entityManager),
|
||||
[],
|
||||
];
|
||||
|
||||
yield[
|
||||
new QueryBuilder($entityManager),
|
||||
new ArrayCollection(),
|
||||
];
|
||||
|
||||
yield[
|
||||
new QueryBuilder($entityManager),
|
||||
[
|
||||
'lorem' => 11,
|
||||
'ipsum' => 22,
|
||||
],
|
||||
];
|
||||
|
||||
yield[
|
||||
new QueryBuilder($entityManager),
|
||||
new ArrayCollection([
|
||||
'lorem' => 11,
|
||||
'ipsum' => 22,
|
||||
]),
|
||||
];
|
||||
|
||||
yield[
|
||||
new QueryBuilder($entityManager),
|
||||
[
|
||||
new Parameter('lorem', 11),
|
||||
new Parameter('ipsum', 22),
|
||||
],
|
||||
];
|
||||
|
||||
yield[
|
||||
new QueryBuilder($entityManager),
|
||||
new ArrayCollection([
|
||||
new Parameter('lorem', 11),
|
||||
new Parameter('ipsum', 22),
|
||||
]),
|
||||
];
|
||||
static::assertSame($queryBuilder, $newQueryBuilder);
|
||||
static::assertCount(0, $newQueryBuilder->getParameters());
|
||||
static::assertNull($newQueryBuilder->getDQLPart('where'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@ class A
|
||||
|
||||
private $count = 1;
|
||||
|
||||
protected function lorem()
|
||||
{
|
||||
return 'ipsum';
|
||||
}
|
||||
|
||||
protected function getCount()
|
||||
{
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
protected function lorem()
|
||||
{
|
||||
return 'ipsum';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@ namespace Meritoo\Test\Common\Utilities\Reflection;
|
||||
*/
|
||||
class C extends B
|
||||
{
|
||||
public function getPositive()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getNegative()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getPositive()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -23,9 +23,174 @@ use Meritoo\Common\Utilities\Uri;
|
||||
*/
|
||||
class UriTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructor()
|
||||
/**
|
||||
* Provides data used to build secured url
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideDataForSecuredUrl()
|
||||
{
|
||||
static::assertHasNoConstructor(Uri::class);
|
||||
yield [
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
];
|
||||
|
||||
yield [
|
||||
'/',
|
||||
'',
|
||||
'',
|
||||
'http://lorem.com/',
|
||||
];
|
||||
|
||||
yield [
|
||||
'contact',
|
||||
'',
|
||||
'',
|
||||
'http://lorem.com/contact',
|
||||
];
|
||||
|
||||
yield [
|
||||
'contact',
|
||||
'john',
|
||||
'',
|
||||
'http://lorem.com/contact',
|
||||
];
|
||||
|
||||
yield [
|
||||
'contact',
|
||||
'',
|
||||
'pass123',
|
||||
'http://lorem.com/contact',
|
||||
];
|
||||
|
||||
yield [
|
||||
'contact',
|
||||
'john',
|
||||
'pass123',
|
||||
'http://john:pass123@lorem.com/contact',
|
||||
];
|
||||
}
|
||||
|
||||
public function provideRootUrlAndUrlParts(): ?Generator
|
||||
{
|
||||
yield [
|
||||
'',
|
||||
'',
|
||||
];
|
||||
|
||||
yield [
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
];
|
||||
|
||||
yield [
|
||||
'http://my.example',
|
||||
'http://my.example',
|
||||
'',
|
||||
];
|
||||
|
||||
yield [
|
||||
'http://my.example',
|
||||
'http://my.example',
|
||||
'',
|
||||
'',
|
||||
];
|
||||
|
||||
yield [
|
||||
'http://my.example//test/12/test/',
|
||||
'http://my.example',
|
||||
'',
|
||||
'test',
|
||||
'12/test',
|
||||
'',
|
||||
];
|
||||
|
||||
yield [
|
||||
'http://my.example//test/12/test',
|
||||
'http://my.example',
|
||||
'',
|
||||
'test/',
|
||||
'12/test/',
|
||||
];
|
||||
|
||||
yield [
|
||||
'http://my.example/test/12/test/',
|
||||
'http://my.example',
|
||||
'/test/',
|
||||
'/12/test',
|
||||
'',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides url to replenish protocol
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideUrlToReplenishProtocol()
|
||||
{
|
||||
yield [
|
||||
'http://test',
|
||||
'test',
|
||||
'',
|
||||
];
|
||||
|
||||
yield [
|
||||
'ftp://lorem.ipsum',
|
||||
'lorem.ipsum',
|
||||
'ftp',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides url used to verify if it's external, from another server / domain
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideUrlToVerifyIfIsExternal()
|
||||
{
|
||||
yield [
|
||||
'',
|
||||
false,
|
||||
];
|
||||
|
||||
yield [
|
||||
'/',
|
||||
false,
|
||||
];
|
||||
|
||||
yield [
|
||||
'http://something.different/first-page',
|
||||
true,
|
||||
];
|
||||
|
||||
yield [
|
||||
'something.different/first-page',
|
||||
true,
|
||||
];
|
||||
|
||||
yield [
|
||||
'http://lorem.com',
|
||||
false,
|
||||
];
|
||||
|
||||
yield [
|
||||
'http://lorem.com/contact',
|
||||
false,
|
||||
];
|
||||
|
||||
yield [
|
||||
'lorem.com',
|
||||
false,
|
||||
];
|
||||
|
||||
yield [
|
||||
'lorem.com/contact',
|
||||
false,
|
||||
];
|
||||
}
|
||||
|
||||
public function testAddProtocolToUrl()
|
||||
@@ -45,61 +210,20 @@ class UriTest extends BaseTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $url Empty value, e.g. ""
|
||||
* @dataProvider provideEmptyValue
|
||||
*/
|
||||
public function testReplenishProtocolEmptyUrl($url)
|
||||
{
|
||||
self::assertEquals('', Uri::replenishProtocol($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $expected Expected result
|
||||
* @param string $url The url to check and replenish
|
||||
* @param string $protocol (optional) The protocol which is replenished. If is empty, protocol of current request
|
||||
* is used.
|
||||
* @param string $expected
|
||||
* @param string $rootUrl
|
||||
* @param string ...$urlParts
|
||||
*
|
||||
* @dataProvider provideUrlToReplenishProtocol
|
||||
* @dataProvider provideRootUrlAndUrlParts
|
||||
*/
|
||||
public function testReplenishProtocol($expected, $url, $protocol = '')
|
||||
public function testBuildUrl(string $expected, string $rootUrl, string ...$urlParts): void
|
||||
{
|
||||
/*
|
||||
* Required to get protocol when it's not provided and to void test failure:
|
||||
*
|
||||
* Failed asserting that two strings are identical.
|
||||
* Expected :'://test'
|
||||
* Actual :'http://test'
|
||||
*/
|
||||
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
|
||||
|
||||
self::assertSame($expected, Uri::replenishProtocol($url, $protocol));
|
||||
static::assertSame($expected, Uri::buildUrl($rootUrl, ...$urlParts));
|
||||
}
|
||||
|
||||
public function testGetServerNameOrIpWithoutProtocol()
|
||||
public function testConstructor()
|
||||
{
|
||||
$_SERVER['HTTP_HOST'] = '';
|
||||
self::assertEquals('', Uri::getServerNameOrIp());
|
||||
|
||||
$host = 'lorem.com';
|
||||
$_SERVER['HTTP_HOST'] = $host;
|
||||
|
||||
self::assertEquals($host, Uri::getServerNameOrIp());
|
||||
}
|
||||
|
||||
public function testGetServerNameOrIpWithProtocol()
|
||||
{
|
||||
$_SERVER['HTTP_HOST'] = '';
|
||||
$_SERVER['SERVER_PROTOCOL'] = '';
|
||||
|
||||
self::assertEquals('', Uri::getServerNameOrIp(true));
|
||||
|
||||
$host = 'lorem.com';
|
||||
$protocol = 'HTTP/1.1';
|
||||
|
||||
$_SERVER['HTTP_HOST'] = $host;
|
||||
$_SERVER['SERVER_PROTOCOL'] = $protocol;
|
||||
|
||||
self::assertEquals(sprintf('http://%s', $host), Uri::getServerNameOrIp(true));
|
||||
static::assertHasNoConstructor(Uri::class);
|
||||
}
|
||||
|
||||
public function testGetFullUriWithHost()
|
||||
@@ -157,6 +281,49 @@ class UriTest extends BaseTestCase
|
||||
self::assertEquals($refererUrl, Uri::getRefererUri());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url A path / url to some resource, e.g. page, image, css file
|
||||
* @param string $user User name used to log in
|
||||
* @param string $password User password used to log in
|
||||
* @param string $expectedUrl Expected, secured url
|
||||
*
|
||||
* @dataProvider provideDataForSecuredUrl
|
||||
*/
|
||||
public function testGetSecuredUrl($url, $user, $password, $expectedUrl)
|
||||
{
|
||||
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
|
||||
$_SERVER['HTTP_HOST'] = 'lorem.com';
|
||||
|
||||
self::assertEquals($expectedUrl, Uri::getSecuredUrl($url, $user, $password));
|
||||
}
|
||||
|
||||
public function testGetServerNameOrIpWithProtocol()
|
||||
{
|
||||
$_SERVER['HTTP_HOST'] = '';
|
||||
$_SERVER['SERVER_PROTOCOL'] = '';
|
||||
|
||||
self::assertEquals('', Uri::getServerNameOrIp(true));
|
||||
|
||||
$host = 'lorem.com';
|
||||
$protocol = 'HTTP/1.1';
|
||||
|
||||
$_SERVER['HTTP_HOST'] = $host;
|
||||
$_SERVER['SERVER_PROTOCOL'] = $protocol;
|
||||
|
||||
self::assertEquals(sprintf('http://%s', $host), Uri::getServerNameOrIp(true));
|
||||
}
|
||||
|
||||
public function testGetServerNameOrIpWithoutProtocol()
|
||||
{
|
||||
$_SERVER['HTTP_HOST'] = '';
|
||||
self::assertEquals('', Uri::getServerNameOrIp());
|
||||
|
||||
$host = 'lorem.com';
|
||||
$_SERVER['HTTP_HOST'] = $host;
|
||||
|
||||
self::assertEquals($host, Uri::getServerNameOrIp());
|
||||
}
|
||||
|
||||
public function testGetUserAddressIp()
|
||||
{
|
||||
$_SERVER['REMOTE_ADDR'] = '';
|
||||
@@ -168,58 +335,49 @@ class UriTest extends BaseTestCase
|
||||
self::assertEquals($userAddressIp, Uri::getUserAddressIp());
|
||||
}
|
||||
|
||||
public function testGetUserOperatingSystemName()
|
||||
{
|
||||
$_SERVER['HTTP_USER_AGENT'] = '';
|
||||
self::assertEquals('', Uri::getUserOperatingSystemName());
|
||||
|
||||
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/600.2.5 (KHTML, like'
|
||||
.' Gecko) Version/8.0.2 Safari/600.2.5';
|
||||
|
||||
self::assertEquals('Mac OS', Uri::getUserOperatingSystemName());
|
||||
}
|
||||
|
||||
public function testGetUserWebBrowserInfo()
|
||||
{
|
||||
$_SERVER['HTTP_USER_AGENT'] = '';
|
||||
self::assertEquals('', Uri::getUserWebBrowserInfo());
|
||||
|
||||
$browserInfo = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/600.2.5 (KHTML, like Gecko)'
|
||||
. ' Version/8.0.2 Safari/600.2.5';
|
||||
.' Version/8.0.2 Safari/600.2.5';
|
||||
|
||||
$_SERVER['HTTP_USER_AGENT'] = $browserInfo;
|
||||
self::assertEquals($browserInfo, Uri::getUserWebBrowserInfo());
|
||||
}
|
||||
|
||||
public function testGetUserWebBrowserNameWithoutVersion()
|
||||
{
|
||||
$_SERVER['HTTP_USER_AGENT'] = '';
|
||||
self::assertEquals('', Uri::getUserWebBrowserName());
|
||||
|
||||
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/600.2.5 (KHTML, like'
|
||||
. ' Gecko) Version/8.0.2 Safari/600.2.5';
|
||||
|
||||
self::assertEquals('Apple Safari', Uri::getUserWebBrowserName());
|
||||
}
|
||||
|
||||
public function testGetUserWebBrowserNameWithVersion()
|
||||
{
|
||||
$_SERVER['HTTP_USER_AGENT'] = '';
|
||||
self::assertEquals('', Uri::getUserWebBrowserName(true));
|
||||
|
||||
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/600.2.5 (KHTML, like'
|
||||
. ' Gecko) Version/8.0.2 Safari/600.2.5';
|
||||
.' Gecko) Version/8.0.2 Safari/600.2.5';
|
||||
|
||||
self::assertEquals('Apple Safari 600.2.5', Uri::getUserWebBrowserName(true));
|
||||
}
|
||||
|
||||
public function testGetUserOperatingSystemName()
|
||||
public function testGetUserWebBrowserNameWithoutVersion()
|
||||
{
|
||||
$_SERVER['HTTP_USER_AGENT'] = '';
|
||||
self::assertEquals('', Uri::getUserOperatingSystemName());
|
||||
self::assertEquals('', Uri::getUserWebBrowserName());
|
||||
|
||||
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/600.2.5 (KHTML, like'
|
||||
. ' Gecko) Version/8.0.2 Safari/600.2.5';
|
||||
.' Gecko) Version/8.0.2 Safari/600.2.5';
|
||||
|
||||
self::assertEquals('Mac OS', Uri::getUserOperatingSystemName());
|
||||
}
|
||||
|
||||
public function testIsServerLocalhost()
|
||||
{
|
||||
$_SERVER['HTTP_HOST'] = '';
|
||||
self::assertFalse(Uri::isServerLocalhost());
|
||||
|
||||
$_SERVER['HTTP_HOST'] = '127.0.0.1';
|
||||
self::assertTrue(Uri::isServerLocalhost());
|
||||
self::assertEquals('Apple Safari', Uri::getUserWebBrowserName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,201 +397,43 @@ class UriTest extends BaseTestCase
|
||||
self::assertEquals($expected, Uri::isExternalUrl($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url A path / url to some resource, e.g. page, image, css file
|
||||
* @param string $user User name used to log in
|
||||
* @param string $password User password used to log in
|
||||
* @param string $expectedUrl Expected, secured url
|
||||
*
|
||||
* @dataProvider provideDataForSecuredUrl
|
||||
*/
|
||||
public function testGetSecuredUrl($url, $user, $password, $expectedUrl)
|
||||
public function testIsServerLocalhost()
|
||||
{
|
||||
$_SERVER['HTTP_HOST'] = '';
|
||||
self::assertFalse(Uri::isServerLocalhost());
|
||||
|
||||
$_SERVER['HTTP_HOST'] = '127.0.0.1';
|
||||
self::assertTrue(Uri::isServerLocalhost());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $expected Expected result
|
||||
* @param string $url The url to check and replenish
|
||||
* @param string $protocol (optional) The protocol which is replenished. If is empty, protocol of current request
|
||||
* is used.
|
||||
*
|
||||
* @dataProvider provideUrlToReplenishProtocol
|
||||
*/
|
||||
public function testReplenishProtocol($expected, $url, $protocol = '')
|
||||
{
|
||||
/*
|
||||
* Required to get protocol when it's not provided and to void test failure:
|
||||
*
|
||||
* Failed asserting that two strings are identical.
|
||||
* Expected :'://test'
|
||||
* Actual :'http://test'
|
||||
*/
|
||||
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
|
||||
$_SERVER['HTTP_HOST'] = 'lorem.com';
|
||||
|
||||
self::assertEquals($expectedUrl, Uri::getSecuredUrl($url, $user, $password));
|
||||
self::assertSame($expected, Uri::replenishProtocol($url, $protocol));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $expected
|
||||
* @param string $rootUrl
|
||||
* @param string ...$urlParts
|
||||
*
|
||||
* @dataProvider provideRootUrlAndUrlParts
|
||||
* @param mixed $url Empty value, e.g. ""
|
||||
* @dataProvider provideEmptyValue
|
||||
*/
|
||||
public function testBuildUrl(string $expected, string $rootUrl, string ...$urlParts): void
|
||||
public function testReplenishProtocolEmptyUrl($url)
|
||||
{
|
||||
static::assertSame($expected, Uri::buildUrl($rootUrl, ...$urlParts));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides url to replenish protocol
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideUrlToReplenishProtocol()
|
||||
{
|
||||
yield[
|
||||
'http://test',
|
||||
'test',
|
||||
'',
|
||||
];
|
||||
|
||||
yield[
|
||||
'ftp://lorem.ipsum',
|
||||
'lorem.ipsum',
|
||||
'ftp',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides url used to verify if it's external, from another server / domain
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideUrlToVerifyIfIsExternal()
|
||||
{
|
||||
yield[
|
||||
'',
|
||||
false,
|
||||
];
|
||||
|
||||
yield[
|
||||
'/',
|
||||
false,
|
||||
];
|
||||
|
||||
yield[
|
||||
'http://something.different/first-page',
|
||||
true,
|
||||
];
|
||||
|
||||
yield[
|
||||
'something.different/first-page',
|
||||
true,
|
||||
];
|
||||
|
||||
yield[
|
||||
'http://lorem.com',
|
||||
false,
|
||||
];
|
||||
|
||||
yield[
|
||||
'http://lorem.com/contact',
|
||||
false,
|
||||
];
|
||||
|
||||
yield[
|
||||
'lorem.com',
|
||||
false,
|
||||
];
|
||||
|
||||
yield[
|
||||
'lorem.com/contact',
|
||||
false,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides data used to build secured url
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideDataForSecuredUrl()
|
||||
{
|
||||
yield[
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
];
|
||||
|
||||
yield[
|
||||
'/',
|
||||
'',
|
||||
'',
|
||||
'http://lorem.com/',
|
||||
];
|
||||
|
||||
yield[
|
||||
'contact',
|
||||
'',
|
||||
'',
|
||||
'http://lorem.com/contact',
|
||||
];
|
||||
|
||||
yield[
|
||||
'contact',
|
||||
'john',
|
||||
'',
|
||||
'http://lorem.com/contact',
|
||||
];
|
||||
|
||||
yield[
|
||||
'contact',
|
||||
'',
|
||||
'pass123',
|
||||
'http://lorem.com/contact',
|
||||
];
|
||||
|
||||
yield[
|
||||
'contact',
|
||||
'john',
|
||||
'pass123',
|
||||
'http://john:pass123@lorem.com/contact',
|
||||
];
|
||||
}
|
||||
|
||||
public function provideRootUrlAndUrlParts(): ?Generator
|
||||
{
|
||||
yield[
|
||||
'',
|
||||
'',
|
||||
];
|
||||
|
||||
yield[
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
];
|
||||
|
||||
yield[
|
||||
'http://my.example',
|
||||
'http://my.example',
|
||||
'',
|
||||
];
|
||||
|
||||
yield[
|
||||
'http://my.example',
|
||||
'http://my.example',
|
||||
'',
|
||||
'',
|
||||
];
|
||||
|
||||
yield[
|
||||
'http://my.example//test/12/test/',
|
||||
'http://my.example',
|
||||
'',
|
||||
'test',
|
||||
'12/test',
|
||||
'',
|
||||
];
|
||||
|
||||
yield[
|
||||
'http://my.example//test/12/test',
|
||||
'http://my.example',
|
||||
'',
|
||||
'test/',
|
||||
'12/test/',
|
||||
];
|
||||
|
||||
yield[
|
||||
'http://my.example/test/12/test/',
|
||||
'http://my.example',
|
||||
'/test/',
|
||||
'/12/test',
|
||||
'',
|
||||
];
|
||||
self::assertEquals('', Uri::replenishProtocol($url));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ use SimpleXMLElement;
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\Xml
|
||||
* @covers \Meritoo\Common\Utilities\Xml
|
||||
*/
|
||||
class XmlTest extends BaseTestCase
|
||||
{
|
||||
@@ -38,14 +38,14 @@ class XmlTest extends BaseTestCase
|
||||
$element2 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><employees />');
|
||||
|
||||
$merged = Xml::mergeNodes($element1, $element2);
|
||||
self::assertEquals('', (string)$merged);
|
||||
self::assertEquals('', (string) $merged);
|
||||
|
||||
// XMLs with data
|
||||
$element1 = new SimpleXMLElement($this->simpleXml);
|
||||
$element2 = new SimpleXMLElement($this->advancedXml);
|
||||
|
||||
$merged = Xml::mergeNodes($element1, $element2);
|
||||
self::assertEquals('John', (string)$merged->author[0]->first_name);
|
||||
self::assertEquals('John', (string) $merged->author[0]->first_name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user