forked from loafle/openapi-generator-original
[PHP] fix PHPUnit invocation, add basic phpunit.xml.dist (#3864)
* feature(phpunit) fix PHPUnit invocation, add basic phpunit.xml.dist * fix(phpunit) add proper paths relative to phpunit.xml.dist
This commit is contained in:
parent
ec25bd793f
commit
10d3dea89e
@ -197,6 +197,12 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
|||||||
|
|
||||||
additionalProperties.put("escapedInvokerPackage", invokerPackage.replace("\\", "\\\\"));
|
additionalProperties.put("escapedInvokerPackage", invokerPackage.replace("\\", "\\\\"));
|
||||||
|
|
||||||
|
// make api and model src path available in mustache template
|
||||||
|
additionalProperties.put("apiSrcPath", "./" + toSrcPath(apiPackage, srcBasePath));
|
||||||
|
additionalProperties.put("modelSrcPath", "./" + toSrcPath(modelPackage, srcBasePath));
|
||||||
|
additionalProperties.put("apiTestPath", "./" + testBasePath + "/" + apiDirName);
|
||||||
|
additionalProperties.put("modelTestPath", "./" + testBasePath + "/" + modelDirName);
|
||||||
|
|
||||||
// make api and model doc path available in mustache template
|
// make api and model doc path available in mustache template
|
||||||
additionalProperties.put("apiDocPath", apiDocPath);
|
additionalProperties.put("apiDocPath", apiDocPath);
|
||||||
additionalProperties.put("modelDocPath", modelDocPath);
|
additionalProperties.put("modelDocPath", modelDocPath);
|
||||||
@ -213,6 +219,10 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toPackagePath(String packageName, String basePath) {
|
public String toPackagePath(String packageName, String basePath) {
|
||||||
|
return (getPackagePath() + File.separatorChar + toSrcPath(packageName, basePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toSrcPath(String packageName, String basePath) {
|
||||||
packageName = packageName.replace(invokerPackage, ""); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
packageName = packageName.replace(invokerPackage, ""); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||||
if (basePath != null && basePath.length() > 0) {
|
if (basePath != null && basePath.length() > 0) {
|
||||||
basePath = basePath.replaceAll("[\\\\/]?$", "") + File.separatorChar; // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
basePath = basePath.replaceAll("[\\\\/]?$", "") + File.separatorChar; // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||||
@ -232,7 +242,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
|||||||
regLastPathSeparator = "\\\\$";
|
regLastPathSeparator = "\\\\$";
|
||||||
}
|
}
|
||||||
|
|
||||||
return (getPackagePath() + File.separatorChar + basePath
|
return (basePath
|
||||||
// Replace period, backslash, forward slash with file separator in package name
|
// Replace period, backslash, forward slash with file separator in package name
|
||||||
+ packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement(File.separator))
|
+ packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement(File.separator))
|
||||||
// Trim prefix file separators from package path
|
// Trim prefix file separators from package path
|
||||||
|
@ -150,6 +150,10 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toPackagePath(String packageName, String basePath) {
|
public String toPackagePath(String packageName, String basePath) {
|
||||||
|
return (getPackagePath() + File.separatorChar + toSrcPath(packageName, basePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toSrcPath(String packageName, String basePath) {
|
||||||
packageName = packageName.replace(invokerPackage, ""); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
packageName = packageName.replace(invokerPackage, ""); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||||
if (basePath != null && basePath.length() > 0) {
|
if (basePath != null && basePath.length() > 0) {
|
||||||
basePath = basePath.replaceAll("[\\\\/]?$", "") + File.separatorChar; // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
basePath = basePath.replaceAll("[\\\\/]?$", "") + File.separatorChar; // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||||
@ -169,7 +173,7 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
regLastPathSeparator = "\\\\$";
|
regLastPathSeparator = "\\\\$";
|
||||||
}
|
}
|
||||||
|
|
||||||
return (getPackagePath() + File.separatorChar + basePath
|
return (basePath
|
||||||
// Replace period, backslash, forward slash with file separator in package name
|
// Replace period, backslash, forward slash with file separator in package name
|
||||||
+ packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement(File.separator))
|
+ packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement(File.separator))
|
||||||
// Trim prefix file separators from package path
|
// Trim prefix file separators from package path
|
||||||
@ -276,6 +280,12 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
additionalProperties.put("escapedInvokerPackage", invokerPackage.replace("\\", "\\\\"));
|
additionalProperties.put("escapedInvokerPackage", invokerPackage.replace("\\", "\\\\"));
|
||||||
|
|
||||||
|
// make api and model src path available in mustache template
|
||||||
|
additionalProperties.put("apiSrcPath", "./" + toSrcPath(apiPackage, srcBasePath));
|
||||||
|
additionalProperties.put("modelSrcPath", "./" + toSrcPath(modelPackage, srcBasePath));
|
||||||
|
additionalProperties.put("apiTestPath", "./" + testBasePath + "/" + apiDirName);
|
||||||
|
additionalProperties.put("modelTestPath", "./" + testBasePath + "/" + modelDirName);
|
||||||
|
|
||||||
// make api and model doc path available in mustache template
|
// make api and model doc path available in mustache template
|
||||||
additionalProperties.put("apiDocPath", apiDocPath);
|
additionalProperties.put("apiDocPath", apiDocPath);
|
||||||
additionalProperties.put("modelDocPath", modelDocPath);
|
additionalProperties.put("modelDocPath", modelDocPath);
|
||||||
@ -290,6 +300,7 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
supportingFiles.add(new SupportingFile("composer.mustache", getPackagePath(), "composer.json"));
|
supportingFiles.add(new SupportingFile("composer.mustache", getPackagePath(), "composer.json"));
|
||||||
supportingFiles.add(new SupportingFile("autoload.mustache", getPackagePath(), "autoload.php"));
|
supportingFiles.add(new SupportingFile("autoload.mustache", getPackagePath(), "autoload.php"));
|
||||||
supportingFiles.add(new SupportingFile("README.mustache", getPackagePath(), "README.md"));
|
supportingFiles.add(new SupportingFile("README.mustache", getPackagePath(), "README.md"));
|
||||||
|
supportingFiles.add(new SupportingFile("phpunit.xml.mustache", getPackagePath(), "phpunit.xml.dist"));
|
||||||
supportingFiles.add(new SupportingFile(".travis.yml", getPackagePath(), ".travis.yml"));
|
supportingFiles.add(new SupportingFile(".travis.yml", getPackagePath(), ".travis.yml"));
|
||||||
supportingFiles.add(new SupportingFile(".php_cs", getPackagePath(), ".php_cs"));
|
supportingFiles.add(new SupportingFile(".php_cs", getPackagePath(), ".php_cs"));
|
||||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", getPackagePath(), "git_push.sh"));
|
supportingFiles.add(new SupportingFile("git_push.sh.mustache", getPackagePath(), "git_push.sh"));
|
||||||
|
@ -7,4 +7,4 @@ php:
|
|||||||
- 7.0
|
- 7.0
|
||||||
- hhvm
|
- hhvm
|
||||||
before_install: "composer install"
|
before_install: "composer install"
|
||||||
script: "phpunit lib/Tests"
|
script: "vendor/bin/phpunit"
|
||||||
|
@ -56,7 +56,7 @@ To run the unit tests:
|
|||||||
|
|
||||||
```
|
```
|
||||||
composer install
|
composer install
|
||||||
./vendor/bin/phpunit lib/Tests
|
./vendor/bin/phpunit
|
||||||
```
|
```
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<phpunit bootstrap="./vendor/autoload.php"
|
||||||
|
colors="true"
|
||||||
|
convertErrorsToExceptions="true"
|
||||||
|
convertNoticesToExceptions="true"
|
||||||
|
convertWarningsToExceptions="true"
|
||||||
|
stopOnFailure="false">
|
||||||
|
<testsuites>
|
||||||
|
<testsuite>
|
||||||
|
<directory>{{apiTestPath}}</directory>
|
||||||
|
<directory>{{modelTestPath}}</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
|
||||||
|
<filter>
|
||||||
|
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||||
|
<directory suffix=".php">{{apiSrcPath}}</directory>
|
||||||
|
<directory suffix=".php">{{modelSrcPath}}</directory>
|
||||||
|
</whitelist>
|
||||||
|
</filter>
|
||||||
|
</phpunit>
|
@ -7,4 +7,4 @@ php:
|
|||||||
- 7.0
|
- 7.0
|
||||||
- hhvm
|
- hhvm
|
||||||
before_install: "composer install"
|
before_install: "composer install"
|
||||||
script: "phpunit lib/Tests"
|
script: "vendor/bin/phpunit"
|
||||||
|
@ -45,7 +45,7 @@ To run the unit tests:
|
|||||||
|
|
||||||
```
|
```
|
||||||
composer install
|
composer install
|
||||||
./vendor/bin/phpunit lib/Tests
|
./vendor/bin/phpunit
|
||||||
```
|
```
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<phpunit bootstrap="./vendor/autoload.php"
|
||||||
|
colors="true"
|
||||||
|
convertErrorsToExceptions="true"
|
||||||
|
convertNoticesToExceptions="true"
|
||||||
|
convertWarningsToExceptions="true"
|
||||||
|
stopOnFailure="false">
|
||||||
|
<testsuites>
|
||||||
|
<testsuite>
|
||||||
|
<directory>./test/Api</directory>
|
||||||
|
<directory>./test/Model</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
|
||||||
|
<filter>
|
||||||
|
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||||
|
<directory suffix=".php">./lib/Api</directory>
|
||||||
|
<directory suffix=".php">./lib/Model</directory>
|
||||||
|
</whitelist>
|
||||||
|
</filter>
|
||||||
|
</phpunit>
|
@ -47,9 +47,6 @@
|
|||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<executable>vendor/bin/phpunit</executable>
|
<executable>vendor/bin/phpunit</executable>
|
||||||
<arguments>
|
|
||||||
<argument>test</argument>
|
|
||||||
</arguments>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user