1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SilverLeague\IDEAnnotator\Tests; |
4
|
|
|
|
5
|
|
|
use PHPUnit_Framework_TestCase; |
6
|
|
|
use SilverLeague\IDEAnnotator\AnnotateClassInfo; |
7
|
|
|
use SilverStripe\Core\Injector\Injector; |
8
|
|
|
use SilverStripe\Core\Config\Config; |
9
|
|
|
use SilverLeague\IDEAnnotator\AnnotatePermissionChecker; |
10
|
|
|
use SilverLeague\IDEAnnotator\DataObjectAnnotator; |
11
|
|
|
use SilverStripe\Dev\SapphireTest; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class DataObjectAnnotatorTest |
15
|
|
|
* |
16
|
|
|
* Several tests to make sure the Annotator does it's job correctly |
17
|
|
|
* |
18
|
|
|
* @mixin PHPUnit_Framework_TestCase |
19
|
|
|
*/ |
20
|
|
|
class ControllerAnnotatorTest extends SapphireTest |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var MockDataObjectAnnotator |
|
|
|
|
24
|
|
|
*/ |
25
|
|
|
private $annotator; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var AnnotatePermissionChecker $permissionChecker |
29
|
|
|
*/ |
30
|
|
|
private $permissionChecker; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Setup Defaults |
34
|
|
|
*/ |
35
|
|
View Code Duplication |
public function setUp() |
|
|
|
|
36
|
|
|
{ |
37
|
|
|
parent::setUp(); |
38
|
|
|
Config::modify()->set(DataObjectAnnotator::class, 'enabled', true); |
39
|
|
|
Config::modify()->set(DataObjectAnnotator::class, 'enabled_modules', ['ideannotator']); |
40
|
|
|
|
41
|
|
|
$this->annotator = Injector::inst()->get(MockDataObjectAnnotator::class); |
42
|
|
|
$this->permissionChecker = Injector::inst()->get(AnnotatePermissionChecker::class); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
View Code Duplication |
public function testPageGetsAnnotated() |
|
|
|
|
46
|
|
|
{ |
47
|
|
|
$classInfo = new AnnotateClassInfo(AnnotatorPageTest::class); |
|
|
|
|
48
|
|
|
$filePath = $classInfo->getClassFilePath(); |
49
|
|
|
|
50
|
|
|
$content = $this->annotator->getGeneratedFileContent(file_get_contents($filePath), AnnotatorPageTest::class); |
51
|
|
|
|
52
|
|
|
$this->assertContains(' * Class \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTest', $content); |
53
|
|
|
$this->assertContains('@property string $SubTitle', $content); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
View Code Duplication |
public function testPageControllerGetsAnnotator() |
|
|
|
|
57
|
|
|
{ |
58
|
|
|
$classInfo = new AnnotateClassInfo(AnnotatorPageTestController::class); |
|
|
|
|
59
|
|
|
$filePath = $classInfo->getClassFilePath(); |
60
|
|
|
|
61
|
|
|
$content = $this->annotator->getGeneratedFileContent( |
62
|
|
|
file_get_contents($filePath), |
63
|
|
|
AnnotatorPageTestController::class |
64
|
|
|
); |
65
|
|
|
|
66
|
|
|
$this->assertContains(' * Class \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTestController', $content); |
67
|
|
|
$this->assertContains('@property \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTest dataRecord', $content); |
68
|
|
|
$this->assertContains('@method \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTest data()', $content); |
69
|
|
|
$this->assertContains('@mixin \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTest', $content); |
70
|
|
|
$this->assertContains('@mixin \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTest_Extension', $content); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Test the generation of annotations for an Extension |
75
|
|
|
*/ |
76
|
|
View Code Duplication |
public function testAnnotateControllerExtension() |
|
|
|
|
77
|
|
|
{ |
78
|
|
|
$classInfo = new AnnotateClassInfo(AnnotatorPageTest_Extension::class); |
|
|
|
|
79
|
|
|
$filePath = $classInfo->getClassFilePath(); |
80
|
|
|
$original = file_get_contents($filePath); |
81
|
|
|
$annotated = $this->annotator->getGeneratedFileContent($original, AnnotatorPageTest_Extension::class); |
82
|
|
|
|
83
|
|
|
$this->assertContains(' * Class \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTest_Extension', $annotated); |
84
|
|
|
$this->assertContains( |
85
|
|
|
'@property \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTestController|\SilverLeague\IDEAnnotator\Tests\AnnotatorPageTest_Extension $owner', |
86
|
|
|
$annotated |
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function tearDown() |
91
|
|
|
{ |
92
|
|
|
parent::tearDown(); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths