Skip to content

Commit

Permalink
Merge pull request #25 from utopia-php/main
Browse files Browse the repository at this point in the history
sync main
  • Loading branch information
lohanidamodar authored May 21, 2024
2 parents cb8dd46 + 2c6e9eb commit 3a53931
Show file tree
Hide file tree
Showing 17 changed files with 173 additions and 816 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Tests"

on: [ pull_request ]
jobs:
test:
name: Tests ${{ matrix.php-versions }}
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.0', '8.1', '8.2', '8.3', 'nightly']

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup PHP ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Compose install
run: composer install --ignore-platform-reqs

- name: Run tests
run: composer test
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

53 changes: 0 additions & 53 deletions Dockerfile

This file was deleted.

5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
},
"autoload-dev": {
"psr-4": {
"Utopia\\Tests\\": "tests/Platform"
"Utopia\\Tests\\": "tests/Platform",
"Utopia\\Unit\\": "tests/unit"
}
},
"require": {
Expand All @@ -28,6 +29,6 @@
"scripts": {
"format": "vendor/bin/pint",
"lint": "vendor/bin/pint --test",
"test": "docker-compose up -d && sleep 10 && docker-compose exec web vendor/bin/phpunit --configuration phpunit.xml"
"test": "vendor/bin/phpunit --configuration phpunit.xml"
}
}
10 changes: 0 additions & 10 deletions docker-compose.yml

This file was deleted.

4 changes: 3 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
stopOnFailure="false"
>
<testsuites>
<testsuite name="unit">
<directory>./tests/unit</directory>
</testsuite>
<testsuite name="Application Test Suite">
<file>./tests/e2e/Client.php</file>
<directory>./tests/</directory>
</testsuite>
</testsuites>
Expand Down
14 changes: 14 additions & 0 deletions src/Platform/Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,18 @@ public function setWorker(Server $worker): self

return $this;
}

/**
* Get env
*
* Method for querying env parameters. If $key is not found $default value will be returned.
*
* @param string $key
* @param string|null $default
* @return mixed
*/
public function getEnv(string $key, string $default = null): mixed
{
return $_SERVER[$key] ?? $default;
}
}
32 changes: 32 additions & 0 deletions tests/Platform/MockResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Utopia\Tests;

use Utopia\Response;

class MockResponse extends Response
{
public function end(string $content = null): void
{
if (! is_null($content)) {
echo $content;
}
}

public function send(string $body = ''): void
{
$this->sent = true;
$this->end($body);
}

public function chunk(string $body = '', bool $end = false): void
{
if ($end) {
$this->sent = true;
}
$this->write($body);
if ($end) {
$this->end();
}
}
}
87 changes: 0 additions & 87 deletions tests/docker/nginx.conf

This file was deleted.

25 changes: 0 additions & 25 deletions tests/docker/start

This file was deleted.

45 changes: 0 additions & 45 deletions tests/docker/supervisord.conf

This file was deleted.

Loading

0 comments on commit 3a53931

Please sign in to comment.