Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
HtmlFormConverterTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class HtmlFormConverterTest extends \PHPUnit\Framework\TestCase
11 {
12  public function testConvert()
13  {
14  $expectedResult = [
15  'parameter1' => 'val1',
16  'parameter2' => 'val2',
17  'parameter3' => 'val3'
18  ];
19 
20  $converter = new HtmlFormConverter();
21  static::assertEquals($expectedResult, $converter->convert($this->getValidFormHtml()));
22  }
23 
24  public function testConvertNotValidHtml()
25  {
26  $converter = new HtmlFormConverter();
27  $result = $converter->convert('Not html. Really not.');
28  $this->assertNotNull($result);
29  }
30 
36  private function getValidFormHtml()
37  {
38  return '
39  <!DOCTYPE HTML>
40  <html>
41  <head>
42  <meta charset="utf-8">
43  <title>Title</title>
44  </head>
45  <body>
46 
47  <form action="some">
48  <p><input type="radio" name="parameter1" value="val1">val1<Br>
49  <input type="radio" name="parameter2" value="val2">val2<Br>
50  <input type="radio" name="parameter3" value="val3">val3</p>
51  <p><input type="submit"></p>
52  </form>
53 
54  </body>
55  </html>
56  ';
57  }
58 }