Skip to content

Commit

Permalink
feat: rename workflow file, depersonalize fixtures, fixed typos;
Browse files Browse the repository at this point in the history
  • Loading branch information
DenTray committed Jan 13, 2023
1 parent 832c89a commit 94d4de8
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 84 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: run-tests-with-coverage
name: Run tests with coverage

on:
push:
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM webdevops/php-nginx:7.3
FROM webdevops/php-nginx-dev:7.3

RUN wget -O "/usr/local/bin/go-replace" "https://github.com/webdevops/goreplace/releases/download/1.1.2/gr-arm64-linux" \
&& chmod +x "/usr/local/bin/go-replace" \
&& "/usr/local/bin/go-replace" --version
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ version: '3'

services:
nginx:
build:
context: ./
dockerfile: "Dockerfile"
build: .
working_dir: /app
ports:
- 80:80
Expand Down
18 changes: 9 additions & 9 deletions tests/RemoteDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class RemoteDriverTest extends TestCase
use MockTrait;

protected $tmpData;
protected $removeDriverClass;
protected $remoteDriverClass;
protected $tmpDocumentationFilePath;

public function setUp(): void
Expand All @@ -21,12 +21,12 @@ public function setUp(): void
$this->tmpData = $this->getJsonFixture('tmp_data');
$this->tmpDocumentationFilePath = __DIR__ . '/../storage/temp_documentation.json';

$this->removeDriverClass = new RemoteDriver();
$this->remoteDriverClass = new RemoteDriver();
}

public function testSaveTmpData()
{
$this->removeDriverClass->saveTmpData($this->tmpData);
$this->remoteDriverClass->saveTmpData($this->tmpData);

$this->assertFileExists($this->tmpDocumentationFilePath);
$this->assertFileEquals($this->generateFixturePath('tmp_data_non_formatted.json'), $this->tmpDocumentationFilePath);
Expand All @@ -36,14 +36,14 @@ public function testGetTmpData()
{
file_put_contents($this->tmpDocumentationFilePath, json_encode($this->tmpData));

$result = $this->removeDriverClass->getTmpData();
$result = $this->remoteDriverClass->getTmpData();

$this->assertEquals($this->tmpData, $result);
}

public function testGetTmpDataNoFile()
{
$result = $this->removeDriverClass->getTmpData();
$result = $this->remoteDriverClass->getTmpData();

$this->assertNull($result);
}
Expand All @@ -53,7 +53,7 @@ public function testSaveData()
config(['auto-doc.drivers.remote.key' => 'mocked_key']);
config(['auto-doc.drivers.remote.url' => 'mocked_url']);

$mock = $this->mockCLass(RemoteDriver::class, ['makeHttpRequest']);
$mock = $this->mockClass(RemoteDriver::class, ['makeHttpRequest']);

$mock
->expects($this->once())
Expand All @@ -75,7 +75,7 @@ public function testSaveDataWithoutTmpFile()
config(['auto-doc.drivers.remote.key' => 'mocked_key']);
config(['auto-doc.drivers.remote.url' => 'mocked_url']);

$mock = $this->mockCLass(RemoteDriver::class, ['makeHttpRequest']);
$mock = $this->mockClass(RemoteDriver::class, ['makeHttpRequest']);

$mock
->expects($this->once())
Expand All @@ -93,7 +93,7 @@ public function testGetDocumentation()
config(['auto-doc.drivers.remote.key' => 'mocked_key']);
config(['auto-doc.drivers.remote.url' => 'mocked_url']);

$mock = $this->mockCLass(RemoteDriver::class, ['makeHttpRequest']);
$mock = $this->mockClass(RemoteDriver::class, ['makeHttpRequest']);

$mock
->expects($this->once())
Expand All @@ -113,7 +113,7 @@ public function testGetDocumentationNoFile()
config(['auto-doc.drivers.remote.key' => 'mocked_key']);
config(['auto-doc.drivers.remote.url' => 'mocked_url']);

$mock = $this->mockCLass(RemoteDriver::class, ['makeHttpRequest']);
$mock = $this->mockClass(RemoteDriver::class, ['makeHttpRequest']);

$mock
->expects($this->once())
Expand Down
24 changes: 3 additions & 21 deletions tests/fixtures/LocalDriverTest/tmp_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@
"description": "Operation successfully done",
"schema": {
"example": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3RcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNTE0NzY0ODAwLCJleHAiOjE1MTQ3Njg0MDAsIm5iZiI6MTUxNDc2NDgwMCwianRpIjoiM2tYM2tXQ3Z0UWdOSjBBOSIsInN1YiI6MiwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.Trk1hpjhczDmu60vgKs1aYPl7wxWNJfNCYcW5mC0LQ8",
"token": "some_token",
"user": {
"id": 2,
"email": "user@test.com",
"deleted_at": null,
"created_at": "2017-11-16 06:08:34",
"updated_at": "2018-01-01 00:00:00",
"role_id": 2,
"clio_user_id": null,
"images_limit": 500,
"state": "confirmed",
"reset_password_hash": null,
"failed_auth_attempts": 0,
Expand All @@ -49,7 +47,6 @@
"last_name": null,
"set_password_hash_created_at": null,
"full_name": "user",
"settings": null,
"new_email": "new_email_test2@test.com",
"is_email_verified": true,
"role": {
Expand All @@ -58,22 +55,7 @@
"created_at": null,
"updated_at": null,
"settable": true
},
"services": [
{
"id": 1,
"name": "500px",
"created_at": "2017-11-16 06:08:34",
"updated_at": "2017-11-16 06:08:34",
"is_photo_service": true,
"allow_not_unique_accounts": false,
"pivot": {
"user_id": 2,
"service_id": 1,
"is_token_expired": 0
}
}
]
}
},
"ttl": 60,
"refresh_ttl": 20160
Expand Down Expand Up @@ -129,7 +111,7 @@
"info": {
"description": "This is automatically collected documentation",
"version": "0.0.0",
"title": "Photoclaim API",
"title": "Project Title",
"termsOfService": "",
"contact": {
"email": "your@email.com"
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"swagger":"2.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[{"in":"body","name":"body","description":"","required":true,"schema":{"$ref":"#\/definitions\/authloginObject"}}],"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3RcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNTE0NzY0ODAwLCJleHAiOjE1MTQ3Njg0MDAsIm5iZiI6MTUxNDc2NDgwMCwianRpIjoiM2tYM2tXQ3Z0UWdOSjBBOSIsInN1YiI6MiwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.Trk1hpjhczDmu60vgKs1aYPl7wxWNJfNCYcW5mC0LQ8","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"clio_user_id":null,"images_limit":500,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","settings":null,"new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true},"services":[{"id":1,"name":"500px","created_at":"2017-11-16 06:08:34","updated_at":"2017-11-16 06:08:34","is_photo_service":true,"allow_not_unique_accounts":false,"pivot":{"user_id":2,"service_id":1,"is_token_expired":0}}]},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Photoclaim API","termsOfService":"","contact":{"email":"your@email.com"}}}
{"swagger":"2.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[{"in":"body","name":"body","description":"","required":true,"schema":{"$ref":"#\/definitions\/authloginObject"}}],"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}}
24 changes: 3 additions & 21 deletions tests/fixtures/RemoteDriverTest/tmp_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@
"description": "Operation successfully done",
"schema": {
"example": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3RcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNTE0NzY0ODAwLCJleHAiOjE1MTQ3Njg0MDAsIm5iZiI6MTUxNDc2NDgwMCwianRpIjoiM2tYM2tXQ3Z0UWdOSjBBOSIsInN1YiI6MiwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.Trk1hpjhczDmu60vgKs1aYPl7wxWNJfNCYcW5mC0LQ8",
"token": "some_token",
"user": {
"id": 2,
"email": "user@test.com",
"deleted_at": null,
"created_at": "2017-11-16 06:08:34",
"updated_at": "2018-01-01 00:00:00",
"role_id": 2,
"clio_user_id": null,
"images_limit": 500,
"state": "confirmed",
"reset_password_hash": null,
"failed_auth_attempts": 0,
Expand All @@ -49,7 +47,6 @@
"last_name": null,
"set_password_hash_created_at": null,
"full_name": "user",
"settings": null,
"new_email": "new_email_test2@test.com",
"is_email_verified": true,
"role": {
Expand All @@ -58,22 +55,7 @@
"created_at": null,
"updated_at": null,
"settable": true
},
"services": [
{
"id": 1,
"name": "500px",
"created_at": "2017-11-16 06:08:34",
"updated_at": "2017-11-16 06:08:34",
"is_photo_service": true,
"allow_not_unique_accounts": false,
"pivot": {
"user_id": 2,
"service_id": 1,
"is_token_expired": 0
}
}
]
}
},
"ttl": 60,
"refresh_ttl": 20160
Expand Down Expand Up @@ -129,7 +111,7 @@
"info": {
"description": "This is automatically collected documentation",
"version": "0.0.0",
"title": "Photoclaim API",
"title": "Project Title",
"termsOfService": "",
"contact": {
"email": "your@email.com"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"swagger":"2.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[{"in":"body","name":"body","description":"","required":true,"schema":{"$ref":"#\/definitions\/authloginObject"}}],"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3RcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNTE0NzY0ODAwLCJleHAiOjE1MTQ3Njg0MDAsIm5iZiI6MTUxNDc2NDgwMCwianRpIjoiM2tYM2tXQ3Z0UWdOSjBBOSIsInN1YiI6MiwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.Trk1hpjhczDmu60vgKs1aYPl7wxWNJfNCYcW5mC0LQ8","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"clio_user_id":null,"images_limit":500,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","settings":null,"new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true},"services":[{"id":1,"name":"500px","created_at":"2017-11-16 06:08:34","updated_at":"2017-11-16 06:08:34","is_photo_service":true,"allow_not_unique_accounts":false,"pivot":{"user_id":2,"service_id":1,"is_token_expired":0}}]},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Photoclaim API","termsOfService":"","contact":{"email":"your@email.com"}}}
{"swagger":"2.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[{"in":"body","name":"body","description":"","required":true,"schema":{"$ref":"#\/definitions\/authloginObject"}}],"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}}
Loading

0 comments on commit 94d4de8

Please sign in to comment.