Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Lint | ||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@master | ||
- name: Set up php${{ matrix.php-versions }} | ||
uses: shivammathur/setup-php@v1 | ||
- name: Install Dependencies | ||
run: composer install --prefer-dist | ||
- name: Setup Nextcloud | ||
run: | | ||
mysql -u root -proot -e "CREATE DATABASE oc_autotest;" | ||
mysql -u root -proot -e "CREATE USER 'oc_autotest'@'localhost' IDENTIFIED BY '';" | ||
mysql -u root -proot -e "GRANT ALL ON oc_autotest.* TO 'oc_autotest'@'localhost';" | ||
cd .. | ||
git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b master server | ||
cp -r notes server/apps/ | ||
php server/occ maintenance:install --database-name oc_autotest --database-user oc_autotest --admin-user admin --admin-pass admin --database mysql --database-pass='' | ||
OC_PASS=test php server/occ user:add --password-from-env --display-name="Test" test | ||
- name: Setup Notes | ||
run: | | ||
php ../server/occ app:enable notes | ||
php ../server/occ app:check-code notes | ||
- name: Start Nextcloud server | ||
run: "php -S localhost:8080 -t ../server/ &" | ||
- name: Test API | ||
run: vendor/bin/phpunit --testdox tests/api/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php declare(strict_types=1); | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class APIv02Test extends TestCase { | ||
private $http; | ||
|
||
protected function setUp() : void { | ||
$this->http = new GuzzleHttp\Client([ | ||
'base_uri' => 'http://localhost:8080/index.php/apps/notes/api/v0.2/', | ||
'auth' => ['test', 'test'], | ||
'http_errors' => false, | ||
]); | ||
} | ||
|
||
public function testGetNotes() : void { | ||
$response = $this->http->request('GET', 'notes'); | ||
$this->assertEquals(200, $response->getStatusCode()); | ||
$this->assertEquals( | ||
"application/json; charset=utf-8", | ||
$response->getHeaders()["Content-Type"][0] | ||
); | ||
// TODO test example notes | ||
// $userAgent = json_decode($response->getBody())->{"..."}; | ||
} | ||
|
||
public function testCreateNote() : void { | ||
// TODO | ||
} | ||
|
||
public function testGetNonExistingNoteFails() : void { | ||
$response = $this->http->request('GET', 'notes/1'); | ||
$this->assertEquals(404, $response->getStatusCode()); | ||
} | ||
|
||
protected function tearDown() : void { | ||
$this->http = null; | ||
} | ||
} | ||
|