diff --git a/.gitattributes b/.gitattributes index 5242788..c8456b6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 \ No newline at end of file +/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 \ No newline at end of file diff --git a/.github/workflows/php83.yml b/.github/workflows/php83.yml index 8003948..e8c2ecd 100644 --- a/.github/workflows/php83.yml +++ b/.github/workflows/php83.yml @@ -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 diff --git a/webfiori/http/APITestCase.php b/webfiori/http/APITestCase.php index d9de0c5..5e5f2f4 100644 --- a/webfiori/http/APITestCase.php +++ b/webfiori/http/APITestCase.php @@ -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); @@ -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); @@ -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);