Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RegexTest.php
Go to the documentation of this file.
1 <?php
7 
8 use \Magento\Framework\Event\Observer\Regex;
9 
13 class RegexTest extends \PHPUnit\Framework\TestCase
14 {
18  protected $regex;
19 
20  protected function setUp()
21  {
22  $this->regex = new Regex();
23  }
24 
25  protected function tearDown()
26  {
27  $this->regex = null;
28  }
29 
36  public function testIsValidFor($pattern, $name, $expectedResult)
37  {
38  $this->regex->setEventRegex($pattern);
39  $eventMock = $this->createMock(\Magento\Framework\Event::class);
40  $eventMock->expects($this->any())
41  ->method('getName')
42  ->will($this->returnValue($name));
43 
44  $this->assertEquals($expectedResult, $this->regex->isValidFor($eventMock));
45  }
46 
50  public function isValidForProvider()
51  {
52  return [
53  ['~_name$~', 'event_name', true],
54  ['~_names$~', 'event_name', false]
55  ];
56  }
57 }
$pattern
Definition: website.php:22
testIsValidFor($pattern, $name, $expectedResult)
Definition: RegexTest.php:36
if(!isset($_GET['name'])) $name
Definition: log.php:14