Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ClassNameExtractorTest.php
Go to the documentation of this file.
1 <?php
7 
8 class ClassNameExtractorTest extends \PHPUnit\Framework\TestCase
9 {
15  public function testGetNameWithNamespace($file, $className)
16  {
17  $classNameExtractor = new \Magento\TestFramework\Utility\ClassNameExtractor();
18  $this->assertEquals(
19  $classNameExtractor->getNameWithNamespace($this->getFileContent($file)),
21  );
22  }
23 
28  {
29  return [
30  [
31  'class_with_namespace.txt',
32  'Magento\ModuleName\SubDirectoryName\Foo'
33  ],
34  [
35  'class_implements_interface.txt',
36  'Magento\ModuleName\SubDirectoryName\Foo'
37  ],
38  [
39  'class_with_comment.txt',
40  'Magento\ModuleName\SubDirectoryName\Foo'
41  ],
42  [
43  'missing_class_keyword.txt',
44  false
45  ],
46  [
47  'class_without_namespace.txt',
48  'Foo'
49  ],
50  [
51  'implements_keyword_on_different_line.txt',
52  'Foo'
53  ],
54  [
55  'extra_whitespaces.txt',
56  'Foo'
57  ]
58  ];
59  }
60 
66  public function testGetName($file, $className)
67  {
68  $classNameExtractor = new \Magento\TestFramework\Utility\ClassNameExtractor();
69  $this->assertEquals(
70  $classNameExtractor->getName($this->getFileContent($file)),
72  );
73  }
74 
78  public function getNameDataProvider()
79  {
80  return [
81  [
82  'class_with_namespace.txt',
83  'Foo'
84  ],
85  [
86  'missing_class_keyword.txt',
87  false
88  ],
89  [
90  'implements_keyword_on_different_line.txt',
91  'Foo'
92  ],
93  [
94  'extra_whitespaces.txt',
95  'Foo'
96  ]
97  ];
98  }
99 
105  public function testGetNamespace($file, $className)
106  {
107  $classNameExtractor = new \Magento\TestFramework\Utility\ClassNameExtractor();
108  $this->assertEquals(
109  $classNameExtractor->getNamespace($this->getFileContent($file)),
110  $className
111  );
112  }
113 
117  public function getNamespaceDataProvider()
118  {
119  return [
120  [
121  'missing_class_keyword.txt',
122  'Magento\ModuleName\SubDirectoryName'
123  ],
124  [
125  'class_without_namespace.txt',
126  false
127  ]
128  ];
129  }
130 
135  private function getFileContent($file)
136  {
137  return file_get_contents(__DIR__ . '/_files/' . $file);
138  }
139 }
return false
Definition: gallery.phtml:36
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31