Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-page-cache
Test
Unit
Model
System
Config
Backend
AccessListTest.php
Go to the documentation of this file.
1
<?php
7
declare(strict_types=1);
8
9
namespace
Magento\PageCache\Test\Unit\Model\System\Config\Backend
;
10
11
use
Magento\PageCache\Model\System\Config\Backend\AccessList
;
12
use PHPUnit\Framework\TestCase;
13
use
Magento\Framework\TestFramework\Unit\Helper\ObjectManager
;
14
use
Magento\Framework\App\Config\ScopeConfigInterface
;
15
16
class
AccessListTest
extends
TestCase
17
{
21
private
$accessList;
22
26
protected
function
setUp
()
27
{
28
$objectManager
=
new
ObjectManager
($this);
29
$configMock = $this->getMockForAbstractClass(
30
ScopeConfigInterface::class
31
);
32
$configMock->expects($this->any())
33
->method(
'getValue'
)
34
->with(
'system/full_page_cache/default'
)
35
->willReturn([
'access_list'
=>
'localhost'
]);
36
$this->accessList =
$objectManager
->getObject(
37
AccessList::class,
38
[
39
'config'
=> $configMock,
40
'data'
=> [
'field'
=>
'access_list'
]
41
]
42
);
43
}
44
48
public
function
getValidValues
(): array
49
{
50
return
[
51
[
'localhost'
,
'localhost'
],
52
[
null
,
'localhost'
],
53
[
'127.0.0.1'
,
'127.0.0.1'
],
54
[
'127.0.0.1, localhost, ::2'
,
'127.0.0.1, localhost, ::2'
],
55
];
56
}
57
63
public
function
testBeforeSave
(
$value
, $expectedValue)
64
{
65
$this->accessList->setValue(
$value
);
66
$this->accessList->beforeSave();
67
$this->assertEquals($expectedValue, $this->accessList->getValue());
68
}
69
73
public
function
getInvalidValues
(): array
74
{
75
return
[
76
[
'\\bull val\\'
],
77
[
'{*I am not an IP*}'
],
78
[
'{*I am not an IP*}, 127.0.0.1'
],
79
];
80
}
81
87
public
function
testBeforeSaveInvalid
(
$value
)
88
{
89
$this->accessList->setValue(
$value
);
90
$this->accessList->beforeSave();
91
}
92
}
Magento\PageCache\Model\System\Config\Backend\AccessList
Definition:
AccessList.php:17
$objectManager
$objectManager
Definition:
bootstrap.php:17
Magento\PageCache\Test\Unit\Model\System\Config\Backend\AccessListTest\getValidValues
getValidValues()
Definition:
AccessListTest.php:48
Magento\PageCache\Test\Unit\Model\System\Config\Backend\AccessListTest\setUp
setUp()
Definition:
AccessListTest.php:26
Magento\PageCache\Test\Unit\Model\System\Config\Backend\AccessListTest
Definition:
AccessListTest.php:16
Magento\PageCache\Test\Unit\Model\System\Config\Backend
Definition:
AccessListTest.php:9
Magento\PageCache\Test\Unit\Model\System\Config\Backend\AccessListTest\testBeforeSave
testBeforeSave($value, $expectedValue)
Definition:
AccessListTest.php:63
$value
$value
Definition:
gender.phtml:16
Magento\Framework\TestFramework\Unit\Helper\ObjectManager
Definition:
ObjectManager.php:13
Magento\PageCache\Test\Unit\Model\System\Config\Backend\AccessListTest\testBeforeSaveInvalid
testBeforeSaveInvalid($value)
Definition:
AccessListTest.php:87
Magento\Framework\App\Config\ScopeConfigInterface
Definition:
ScopeConfigInterface.php:15
Magento\PageCache\Test\Unit\Model\System\Config\Backend\AccessListTest\getInvalidValues
getInvalidValues()
Definition:
AccessListTest.php:73