Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #73

Merged
merged 4 commits into from
Dec 24, 2024
Merged

Dev #73

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
#perform LF normalization
* text eol=crlf
*.php text eol=crlf
*.html text eol=crlf
# Files and folders here will be not included when creating package
/tests export-ignore
/examples export-ignore
/.github export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml export-ignore
/sonar-project.properties export-ignore
/phpunit.xml export-ignore
/ecs.php export-ignore
/php_cs.php.dist export-ignore
/phpbench.json export-ignore
/sonar-project.properties export-ignore
/ecs.php export-ignore
/CHANGELOG.md export-ignore
/release-commit.php export-ignore
/release-please-manifest.json export-ignore
/release-please-config.json export-ignore
2 changes: 1 addition & 1 deletion .github/workflows/php83.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
- uses: google-github-actions/release-please-action@v3
- uses: google-github-actions/release-please-action@v4
with:
release-type: php
config-file: release-please-config.json
Expand Down
26 changes: 24 additions & 2 deletions webfiori/http/APITestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function addFile(string $fileIdx, string $filePath, bool $reset = false)
* @return string The method will return the output of the endpoint.
*/
public function callEndpoint(WebServicesManager $manager, string $requestMethod, string $apiEndpointName, array $parameters = [], array $httpHeaders = []) : string {
$manager->setOutputStream(fopen(self::DEFAULT_OUTPUT_STREAM,'w'));
$manager->setOutputStream(fopen($this->getOutputFile(),'w'));
$method = strtoupper($requestMethod);
putenv('REQUEST_METHOD='.$method);

Expand All @@ -128,7 +128,7 @@ public function callEndpoint(WebServicesManager $manager, string $requestMethod,
}

$retVal = $manager->readOutputStream();
unlink(self::DEFAULT_OUTPUT_STREAM);
unlink($this->getOutputFile());

try {
$json = Json::decode($retVal);
Expand All @@ -139,6 +139,28 @@ public function callEndpoint(WebServicesManager $manager, string $requestMethod,
}

}
/**
* Creates a formatted string from calling an API.
*
* This helper method can be used to format JSON output of calling an API
* and use it in assertions. The goal of the method is to initially format
* the out put, display it as string and the developer copies the output
* and modify it as needed.
*
* @param string $output
*/
public function format(string $output) {
$expl = explode(self::NL, $output);
$nl = '.self::NL\n';
$count = count($expl);

for ($x = 0 ; $x < count($expl) ; $x++) {
if ($x + 1 == $count) {
$nl = '';
}
echo ". '$expl[$x]]'".$nl;
}
}
private function parseVal($val) {
$type = gettype($val);

Expand Down
Loading