Source of file AnnotateChangedDBSpecsTest.php
Size: 2,687 Bytes - Last Modified: 2021-12-23T10:24:49+00:00
/var/www/docs.ssmods.com/process/src/tests/unit/AnnotateChangedDBSpecsTest.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 | <?php namespace SilverLeague\IDEAnnotator\Tests; use PHPUnit_Framework_TestCase; use SilverLeague\IDEAnnotator\DataObjectAnnotator; use SilverLeague\IDEAnnotator\Helpers\AnnotateClassInfo; use SilverLeague\IDEAnnotator\Helpers\AnnotatePermissionChecker; use SilverStripe\Control\Director; use SilverStripe\Core\Config\Config; use SilverStripe\Core\Injector\Injector; use SilverStripe\Dev\SapphireTest; /** * This test should fail, if a DB property is removed from * a class, but the property itself still exists after generation * * @mixin PHPUnit_Framework_TestCase */ class AnnotateChangedDBSpecsTest extends SapphireTest { /** * @var MockDataObjectAnnotator */ protected $annotator; /** * @var AnnotatePermissionChecker */ protected $permissionChecker; public function testChangedDBSpecifications() { $classInfo = new AnnotateClassInfo(TeamChanged::class); $filePath = $classInfo->getClassFilePath(); $content = $this->annotator->getGeneratedFileContent(file_get_contents($filePath), TeamChanged::class); $this->assertNotContains('VisitCount', $content); } public function testNonSupportedTagsWillNotBeTouched() { $classInfo = new AnnotateClassInfo(TeamChanged::class); $filePath = $classInfo->getClassFilePath(); $content = $this->annotator->getGeneratedFileContent(file_get_contents($filePath), TeamChanged::class); $this->assertContains('Simon', $content); } public function testManuallyCommentedTagsWillNotBeRemoved() { Config::modify()->set(TeamChanged::class, 'extensions', [Team_Extension::class]); $classInfo = new AnnotateClassInfo(TeamChanged::class); $filePath = $classInfo->getClassFilePath(); $content = $this->annotator->getGeneratedFileContent(file_get_contents($filePath), TeamChanged::class); $this->assertContains('The Team Name', $content); $this->assertContains('This adds extra methods', $content); $this->assertContains('This is the Boss', $content); } public function tearDown() { parent::tearDown(); } /** * Setup Defaults */ protected function setUp() { parent::setUp(); Config::modify()->set(Director::class, 'environment_type', 'dev'); Config::modify()->set(DataObjectAnnotator::class, 'enabled', true); Config::modify()->set(DataObjectAnnotator::class, 'enabled_modules', ['ideannotator']); Config::modify()->merge(TeamChanged::class, 'extensions', [Team_Extension::class]); $this->annotator = Injector::inst()->get(MockDataObjectAnnotator::class); } } |