Skip to content

Commit 165616d

Browse files
author
Igor Melnikov
committed
MAGETWO-63001: Create static test
- improving static test
1 parent 270000b commit 165616d

File tree

12 files changed

+229
-0
lines changed

12 files changed

+229
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Test\Utility\File;
7+
8+
use Magento\TestFramework\Utility\CodeCheck;
9+
10+
class CodeCheckTest extends \PHPUnit_Framework_TestCase
11+
{
12+
/**
13+
* @var CodeCheck
14+
*/
15+
private $checkCode;
16+
17+
protected function setUp()
18+
{
19+
$this->checkCode = new CodeCheck();
20+
}
21+
22+
/**
23+
* @param string $fileContent
24+
* @param bool $isClassUsed
25+
* @dataProvider isClassUsedDataProvider
26+
*/
27+
public function testIsClassUsed($fileContent, $isClassUsed)
28+
{
29+
$this->assertEquals(
30+
$isClassUsed,
31+
$this->checkCode->isClassUsed('MyClass', $fileContent)
32+
);
33+
}
34+
35+
/**
36+
* @return array
37+
*/
38+
public function isClassUsedDataProvider()
39+
{
40+
return [
41+
[file_get_contents(__DIR__ . '/_files/create_new_instance.txt'), true],
42+
[file_get_contents(__DIR__ . '/_files/create_new_instance2.txt'), true],
43+
[file_get_contents(__DIR__ . '/_files/create_new_instance3.txt'), true],
44+
[file_get_contents(__DIR__ . '/_files/class_name_in_namespace_and_variable_name.txt'), false],
45+
[file_get_contents(__DIR__ . '/_files/extends.txt'), true],
46+
[file_get_contents(__DIR__ . '/_files/extends2.txt'), true],
47+
[file_get_contents(__DIR__ . '/_files/use.txt'), true],
48+
[file_get_contents(__DIR__ . '/_files/use2.txt'), true]
49+
];
50+
}
51+
52+
/**
53+
* @param string $fileContent
54+
* @param bool $isDirectDescendant
55+
* @dataProvider isDirectDescendantDataProvider
56+
*/
57+
public function testIsDirectDescendant($fileContent, $isDirectDescendant)
58+
{
59+
$this->assertEquals(
60+
$isDirectDescendant,
61+
$this->checkCode->isDirectDescendant($fileContent, 'MyClass')
62+
);
63+
}
64+
65+
/**
66+
* @return array
67+
*/
68+
public function isDirectDescendantDataProvider()
69+
{
70+
return [
71+
[file_get_contents(__DIR__ . '/_files/extends.txt'), true],
72+
[file_get_contents(__DIR__ . '/_files/extends2.txt'), true],
73+
[file_get_contents(__DIR__ . '/_files/implements.txt'), true],
74+
[file_get_contents(__DIR__ . '/_files/implements2.txt'), true]
75+
];
76+
}
77+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\MyClass;
7+
8+
$myClass
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
$myClass = new MyClass();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
$myClass = new MyClass;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
$myClass = new \MyClass();
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
MyClassChild extends MyClass
8+
{
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
MyClassChild extends \MyClass
8+
{
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
MyClassChild implements MyClass
8+
{
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
MyClassChild implements \MyClass
8+
{
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\MyNamespace;
7+
8+
use MyClass;

0 commit comments

Comments
 (0)