Skip to content

Commit

Permalink
update readme and test location
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed Nov 22, 2024
1 parent ec63cdc commit 4b78fdd
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,21 @@ The dev environment provides a MySQL server, mail server, s3 server, and should
Additionally, Xdebug is enabled, but you will have to modify your
IDE key in the ``.dev/xdebug.ini`` file(or alternatively, on your IDE). You also need to have port 9003 temporarily open on your firewall so you can utilize it effectively. This is because connections from docker to the host will count as external inbound connections
<br /><br />

### Run Tests

Static Analysis `make phpstan`<br />
Code Style `make test-code-style` (to fix code style automatically use `make fix-code-style`)<br />
Unit Tests `make unit-test`<br />
Acceptance Tests `make acceptance-test`<br /> (requires docker)

You can test individual acceptance test groups directly using:<br />
For api: <br />
`docker compose --file .dev/docker-compose.yaml --file .dev/docker-compose.tests.yaml exec leantime-dev php vendor/bin/codecept run -g api --steps`<br />
For timesheets: <br />
`docker compose --file .dev/docker-compose.yaml --file .dev/docker-compose.tests.yaml exec leantime-dev php vendor/bin/codecept run -g timesheet --steps`<br />


### 🏗 Update ###

#### Manual
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Acceptance;
namespace Acceptance\API;

use Codeception\Attribute\Group;
use Tests\Support\AcceptanceTester;
Expand Down
2 changes: 2 additions & 0 deletions tests/Support/ApiTester.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

namespace Tests\Support;

/**
* Inherited Methods
*
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
Expand Down
1 change: 1 addition & 0 deletions tests/Support/Helper/Api.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Tests\Support\Helper;

use Codeception\Module;
Expand Down
25 changes: 15 additions & 10 deletions tests/Unit/app/Domain/Api/Controllers/JsonrpcTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class JsonrpcTest extends TestCase
{
private Jsonrpc $controller;

private Template $template;

protected function setUp(): void
Expand All @@ -25,14 +26,15 @@ public function testMethodStringParsing()
'method' => 'leantime.rpc.Comments.pollComments',
'params' => ['projectId' => 1],
'id' => 1,
'jsonrpc' => '2.0'
'jsonrpc' => '2.0',
];

$this->template->expects($this->once())
->method('displayJson')
->willReturnCallback(function($response) {
->willReturnCallback(function ($response) {
$this->assertArrayHasKey('jsonrpc', $response);
$this->assertEquals('2.0', $response['jsonrpc']);

return response()->json($response);
});

Expand All @@ -45,14 +47,15 @@ public function testInvalidMethodString()
'method' => 'invalid.method.string',
'params' => ['projectId' => 1],
'id' => 1,
'jsonrpc' => '2.0'
'jsonrpc' => '2.0',
];

$this->template->expects($this->once())
->method('displayJson')
->willReturnCallback(function($response) {
->willReturnCallback(function ($response) {
$this->assertArrayHasKey('error', $response);
$this->assertEquals(-32602, $response['error']['code']);

return response()->json($response);
});

Expand All @@ -64,14 +67,15 @@ public function testMissingJsonRpcVersion()
$params = [
'method' => 'leantime.rpc.Comments.pollComments',
'params' => ['projectId' => 1],
'id' => 1
'id' => 1,
];

$this->template->expects($this->once())
->method('displayJson')
->willReturnCallback(function($response) {
->willReturnCallback(function ($response) {
$this->assertArrayHasKey('error', $response);
$this->assertEquals(-32600, $response['error']['code']);

return response()->json($response);
});

Expand All @@ -85,21 +89,22 @@ public function testBatchRequest()
'method' => 'leantime.rpc.Comments.pollComments',
'params' => ['projectId' => 1],
'id' => 1,
'jsonrpc' => '2.0'
'jsonrpc' => '2.0',
],
[
'method' => 'leantime.rpc.Comments.pollComments',
'params' => ['projectId' => 2],
'id' => 2,
'jsonrpc' => '2.0'
]
'jsonrpc' => '2.0',
],
];

$this->template->expects($this->once())
->method('displayJson')
->willReturnCallback(function($response) {
->willReturnCallback(function ($response) {
$this->assertIsArray($response);
$this->assertCount(2, $response);

return response()->json($response);
});

Expand Down

0 comments on commit 4b78fdd

Please sign in to comment.