@@ -33,32 +33,58 @@ public function replaceVersionReplacesProperVersionOfEmConf(): void
3333 }
3434
3535 /**
36- * @test
36+ * @return \Generator<string, array{string, string, string}>
3737 */
38- public function replaceVersionReplacesProperReleaseOfDocumentationConfiguration (): void
38+ public static function replaceVersionReplacesProperReleaseOfDocumentationConfigurationDataProvider (): \ Generator
3939 {
40- $ docSettings = file_get_contents (__DIR__ . '/../Fixtures/Documentation/Settings.cfg ' );
41- $ tempFile = tempnam ('/tmp/ ' , 'tailor_settings.cfg ' );
40+ yield 'guides.xml ' => ['guides.xml ' , 'release="([0-9]+\.[0-9]+\.[0-9]+)" ' , 'release="6.9.0" ' ];
41+ yield 'Settings.cfg ' => ['Settings.cfg ' , 'release\s*=\s*([0-9]+\.[0-9]+\.[0-9]+) ' , 'release=6.9.0 ' ];
42+ }
43+
44+ /**
45+ * @test
46+ * @dataProvider replaceVersionReplacesProperReleaseOfDocumentationConfigurationDataProvider
47+ */
48+ public function replaceVersionReplacesProperReleaseOfDocumentationConfiguration (
49+ string $ docSettingsFile ,
50+ string $ docReleasePattern ,
51+ string $ expected
52+ ): void {
53+ $ docSettings = file_get_contents (__DIR__ . '/../Fixtures/Documentation/ ' . $ docSettingsFile );
54+ $ tempFile = tempnam (sys_get_temp_dir (), 'tailor_ ' . $ docSettingsFile );
4255 file_put_contents ($ tempFile , $ docSettings );
4356 $ subject = new VersionReplacer ('6.9.0 ' );
44- $ subject ->setVersion ($ tempFile , ' release\s*=\s*([0-9]+\.[0-9]+\.[0-9]+) ' );
57+ $ subject ->setVersion ($ tempFile , $ docReleasePattern );
4558 $ contents = file_get_contents ($ tempFile );
46- self ::assertStringContainsString (' release=6.9.0 ' , preg_replace ('/\s+/ ' , '' , $ contents ));
59+ self ::assertStringContainsString ($ expected , preg_replace ('/\s+/ ' , '' , $ contents ));
4760 unlink ($ tempFile );
4861 }
4962
5063 /**
51- * @test
64+ * @return \Generator<string, array{string, string, string}>
5265 */
53- public function replaceVersionReplacesProperVersionOfDocumentationConfiguration (): void
66+ public static function replaceVersionReplacesProperVersionOfDocumentationConfigurationDataProvider (): \ Generator
5467 {
55- $ docSettings = file_get_contents (__DIR__ . '/../Fixtures/Documentation/Settings.cfg ' );
56- $ tempFile = tempnam ('/tmp/ ' , 'tailor_settings.cfg ' );
68+ yield 'guides.xml ' => ['guides.xml ' , 'version="([0-9]+\.[0-9]+)" ' , 'version="6.9" ' ];
69+ yield 'Settings.cfg ' => ['Settings.cfg ' , 'version\s*=\s*([0-9]+\.[0-9]+) ' , 'version=6.9 ' ];
70+ }
71+
72+ /**
73+ * @test
74+ * @dataProvider replaceVersionReplacesProperVersionOfDocumentationConfigurationDataProvider
75+ */
76+ public function replaceVersionReplacesProperVersionOfDocumentationConfiguration (
77+ string $ docSettingsFile ,
78+ string $ docVersionPattern ,
79+ string $ expected
80+ ): void {
81+ $ docSettings = file_get_contents (__DIR__ . '/../Fixtures/Documentation/ ' . $ docSettingsFile );
82+ $ tempFile = tempnam (sys_get_temp_dir (), 'tailor_ ' . $ docSettingsFile );
5783 file_put_contents ($ tempFile , $ docSettings );
5884 $ subject = new VersionReplacer ('6.9.0 ' );
59- $ subject ->setVersion ($ tempFile , ' version\s*=\s*([0-9]+\.[0-9]+) ' , 2 );
85+ $ subject ->setVersion ($ tempFile , $ docVersionPattern , 2 );
6086 $ contents = file_get_contents ($ tempFile );
61- self ::assertStringContainsString (' version=6.9 ' , preg_replace ('/\s+/ ' , '' , $ contents ));
87+ self ::assertStringContainsString ($ expected , preg_replace ('/\s+/ ' , '' , $ contents ));
6288 unlink ($ tempFile );
6389 }
6490
0 commit comments