19 'sprintf' => \Magento\Framework\Filter\Sprintf::class,
20 'template' => \Magento\Framework\Filter\Template::class,
21 'arrayFilter' => \Magento\Framework\Filter\ArrayFilter::class,
28 \Magento\Framework\Filter\Template::class =>
true,
29 \Magento\Framework\Filter\ArrayFilter::class =>
false,
39 $this->_objectManager = $this->createMock(\
Magento\Framework\ObjectManagerInterface::class);
41 $this->_factory = $this->getMockForAbstractClass(
42 \
Magento\Framework\Filter\AbstractFactory::class,
43 [
'objectManger' => $this->_objectManager]
45 $property = new \ReflectionProperty(\
Magento\Framework\Filter\AbstractFactory::class,
'invokableClasses');
46 $property->setAccessible(
true);
47 $property->setValue($this->_factory, $this->_invokableList);
49 $property = new \ReflectionProperty(\
Magento\Framework\Filter\AbstractFactory::class,
'shared');
50 $property->setAccessible(
true);
51 $property->setValue($this->_factory, $this->_sharedList);
61 $this->assertEquals($expectedResult, $this->_factory->canCreateFilter(
$alias));
69 return [[
'arrayFilter',
true], [
'notExist',
false]];
79 $this->assertEquals($expectedResult, $this->_factory->isShared(
$alias));
88 'shared' => [\Magento\Framework\Filter\Template::class,
true],
89 'not shared' => [\Magento\Framework\Filter\ArrayFilter::class,
false],
90 'default value' => [\Magento\Framework\Filter\Sprintf::class,
true]
102 $property = new \ReflectionProperty(\
Magento\Framework\Filter\AbstractFactory::class,
'sharedInstances');
103 $property->setAccessible(
true);
105 $filterMock = $this->getMockBuilder(
'FactoryInterface')->setMethods([
'filter'])->getMock();
106 $this->_objectManager->expects(
111 $this->equalTo($this->_invokableList[
$alias]),
114 $this->returnValue($filterMock)
117 $this->assertEquals($filterMock, $this->_factory->createFilter(
$alias,
$arguments));
119 $sharedList = $property->getValue($this->_factory);
120 $this->assertTrue(array_key_exists(
$alias, $sharedList));
121 $this->assertEquals($filterMock, $sharedList[
$alias]);
123 $this->assertEmpty($property->getValue($this->_factory));
133 'not shared with args' => [
'arrayFilter', [
'123',
'231'],
false],
134 'not shared without args' => [
'arrayFilter', [],
true],
135 'shared' => [
'template', [],
true],
136 'default shared' => [
'sprintf', [],
true]
testCreateFilter($alias, $arguments, $isShared)
createFilterDataProvider()
testIsShared($alias, $expectedResult)
canCreateFilterDataProvider()
testCanCreateFilter($alias, $expectedResult)