diff --git a/tests/Unit/Composer/Extra/StraussConfigTest.php b/tests/Unit/Composer/Extra/StraussConfigTest.php index ca07575f..2b850c14 100644 --- a/tests/Unit/Composer/Extra/StraussConfigTest.php +++ b/tests/Unit/Composer/Extra/StraussConfigTest.php @@ -1,6 +1,6 @@ assertEquals("My_Mozart_Config", $sut->getNamespacePrefix()); } + + public function testIncludeModifiedDateDefaultTrue() + { + + $composerExtraStraussJson = <<<'EOD' +{ + "extra":{ + "strauss": { + "namespace_prefix": "BrianHenryIE\\Strauss\\" + } + } +} +EOD; + $tmpfname = tempnam(sys_get_temp_dir(), 'strauss-test-'); + file_put_contents($tmpfname, $composerExtraStraussJson); + + $composer = Factory::create(new NullIO(), $tmpfname); + + $sut = new StraussConfig($composer); + + $this->assertTrue($sut->isIncludeModifiedDate()); + } + + /** + * "when I add "include_modified_date": false to the extra/strauss object it doesn't take any effect, the date is still added to the header." + * + * @see https://github.com/BrianHenryIE/strauss/issues/35 + */ + public function testIncludeModifiedDate() + { + + $composerExtraStraussJson = <<<'EOD' +{ + "extra":{ + "strauss": { + "namespace_prefix": "BrianHenryIE\\Strauss\\", + "include_modified_date": false + } + } +} +EOD; + $tmpfname = tempnam(sys_get_temp_dir(), 'strauss-test-'); + file_put_contents($tmpfname, $composerExtraStraussJson); + + $composer = Factory::create(new NullIO(), $tmpfname); + + $sut = new StraussConfig($composer); + + $this->assertFalse($sut->isIncludeModifiedDate()); + } } diff --git a/tests/Unit/LicenserTest.php b/tests/Unit/LicenserTest.php index 98051c5d..be53efa8 100644 --- a/tests/Unit/LicenserTest.php +++ b/tests/Unit/LicenserTest.php @@ -71,9 +71,6 @@ public function testFindLicenceFilesPathsAreRelative() * @see https://www.phpliveregex.com/p/A5y */ - // https://schibsted.com/blog/mocking-the-file-system-using-phpunit-and-vfsstream/ - - /** * @see https://github.com/AuthorizeNet/sdk-php/blob/a3e76f96f674d16e892f87c58bedb99dada4b067/lib/net/authorize/api/contract/v1/ANetApiRequestType.php * @@ -106,6 +103,49 @@ public function testAppendHeaderCommentInformationNoHeader() * @see https://github.com/BrianHenryIE/strauss */ +namespace net\authorize\api\contract\v1; +EOD; + + $actual = $sut->addChangeDeclarationToPhpString($given, '25-April-2021', 'proprietary'); + + $this->assertEquals($expected, $actual); + } + + + // https://schibsted.com/blog/mocking-the-file-system-using-phpunit-and-vfsstream/ + + /** + * Not including the date was reported as not working. + * + * @see https://github.com/BrianHenryIE/strauss/issues/35 + * + * @covers ::addChangeDeclarationToPhpString + */ + public function testAppendHeaderCommentNoDate() + { + + $author = 'BrianHenryIE'; + + $config = $this->createMock(StraussConfig::class); + $config->expects($this->once())->method('isIncludeModifiedDate')->willReturn(false); + + $sut = new Licenser($config, __DIR__, array(), $author); + + $given = <<<'EOD' +