Skip to content

Commit

Permalink
improve Code styles in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sysix committed Nov 25, 2023
1 parent 86a4166 commit 36fe494
Show file tree
Hide file tree
Showing 18 changed files with 76 additions and 58 deletions.
3 changes: 2 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
parameters:
level: 8
paths:
- src
- src
- tests
14 changes: 10 additions & 4 deletions tests/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Sysix\LexOffice\Tests;

use Sysix\LexOffice\Api;
use Sysix\LexOffice\Clients\Contact;
use Sysix\LexOffice\Clients\Country;
use Sysix\LexOffice\Clients\CreditNote;
Expand All @@ -19,9 +20,14 @@
use Sysix\LexOffice\Clients\VoucherList;
use Sysix\LexOffice\Clients\RecurringTemplate;
use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\MockObject\MockObject;

class ApiTest extends TestClient
{
/**
* @param Response $response
* @return Api&MockObject
*/
public function createApiMockObject(Response $response)
{
$stub = parent::createApiMockObject($response);
Expand All @@ -30,7 +36,7 @@ public function createApiMockObject(Response $response)
return $stub;
}

public function testClients()
public function testClients(): void
{
$stub = $this->createApiMockObject(new Response());

Expand All @@ -52,7 +58,7 @@ public function testClients()
$this->assertInstanceOf(PostingCategory::class, $stub->postingCategory());
}

public function testApiUrl()
public function testApiUrl(): void
{
$stub = $this->createApiMockObject(
new Response(200, [], 'post-content')
Expand All @@ -66,7 +72,7 @@ public function testApiUrl()
$this->assertStringStartsWith('test.de', $stub->request->getUri()->getHost());
}

public function testGetResponse()
public function testGetResponse(): void
{
$responseMock = new Response(200, [], 'response-body');
$stub = $this->createApiMockObject($responseMock);
Expand All @@ -80,7 +86,7 @@ public function testGetResponse()
$this->assertEquals($responseMock->getReasonPhrase(), $response->getReasonPhrase());
}

public function testRequestHeaders()
public function testRequestHeaders(): void
{
$stub = $this->createApiMockObject(
new Response(200, [], 'post-content')
Expand Down
8 changes: 4 additions & 4 deletions tests/Clients/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class ContactTest extends TestClient
{
public function testGenerateUrl()
public function testGenerateUrl(): void
{
$stub = $this->createClientMockObject(
Contact::class,
Expand All @@ -21,7 +21,7 @@ public function testGenerateUrl()
);
}

public function testCreate()
public function testCreate(): void
{
$stub = $this->createClientMockObject(
Contact::class,
Expand All @@ -35,7 +35,7 @@ public function testCreate()
$this->assertEquals('body', $response->getBody()->__toString());
}

public function testGet()
public function testGet(): void
{
$stub = $this->createClientMockObject(
Contact::class,
Expand All @@ -47,7 +47,7 @@ public function testGet()
$this->assertEquals('body', $response->getBody()->__toString());
}

public function testUpdate()
public function testUpdate(): void
{
$stub = $this->createClientMockObject(
Contact::class,
Expand Down
2 changes: 1 addition & 1 deletion tests/Clients/CountryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class CountryTest extends TestClient
{
public function testGetAll()
public function testGetAll(): void
{
$stub = $this->createClientMockObject(
Country::class,
Expand Down
6 changes: 3 additions & 3 deletions tests/Clients/CreditNoteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class CreditNoteTest extends TestClient
{
public function testCreate()
public function testCreate(): void
{
$stub = $this->createClientMockObject(
CreditNote::class,
Expand All @@ -22,7 +22,7 @@ public function testCreate()
$this->assertEquals('body', $response->getBody()->__toString());
}

public function testGetAll()
public function testGetAll(): void
{
$stub = $this->createClientMockObject(
CreditNote::class,
Expand All @@ -34,7 +34,7 @@ public function testGetAll()
$this->assertEquals('{"content": [], "totalPages": 1}', $response->getBody()->__toString());
}

public function testDocument()
public function testDocument(): void
{
$stub = $this->createClientMockObject(
CreditNote::class,
Expand Down
4 changes: 2 additions & 2 deletions tests/Clients/DownPaymentInvoiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class DownPaymentInvoiceTest extends TestClient
{
public function testGetAll()
public function testGetAll(): void
{
$stub = $this->createClientMockObject(
DownPaymentInvoice::class,
Expand All @@ -20,7 +20,7 @@ public function testGetAll()
$this->assertEquals('{"content": [], "totalPages": 1}', $response->getBody()->__toString());
}

public function testDocument()
public function testDocument(): void
{
$stub = $this->createClientMockObject(
DownPaymentInvoice::class,
Expand Down
6 changes: 3 additions & 3 deletions tests/Clients/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class EventTest extends TestClient
{

public function testCreate()
public function testCreate(): void
{
$stub = $this->createClientMockObject(
Event::class,
Expand All @@ -23,7 +23,7 @@ public function testCreate()
$this->assertEquals('body', $response->getBody()->__toString());
}

public function testGetAll()
public function testGetAll(): void
{
$stub = $this->createClientMockObject(
Event::class,
Expand All @@ -35,7 +35,7 @@ public function testGetAll()
$this->assertEquals('{"content": [], "totalPages": 1}', $response->getBody()->__toString());
}

public function testDelete()
public function testDelete(): void
{
$stub = $this->createClientMockObject(
Event::class,
Expand Down
22 changes: 16 additions & 6 deletions tests/Clients/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class FileTest extends TestClient
{
public function testUploadNotSupportedExtension()
public function testUploadNotSupportedExtension(): void
{
$this->expectException(LexOfficeApiException::class);

Expand All @@ -22,7 +22,7 @@ public function testUploadNotSupportedExtension()
$stub->upload('not_allowed.gif', 'voucher');
}

public function testUploadNotFound()
public function testUploadNotFound(): void
{
$this->expectException(LexOfficeApiException::class);

Expand All @@ -34,7 +34,7 @@ public function testUploadNotFound()
$stub->upload('not_existing.jpg', 'voucher');
}

public function testUploadToBig()
public function testUploadToBig(): void
{
$this->expectException(LexOfficeApiException::class);

Expand All @@ -45,7 +45,12 @@ public function testUploadToBig()

$this->createCacheDir();
$file = $this->getCacheDir() . '/somefile.jpg';
$fp = fopen($file, 'w+'); //
$fp = fopen($file, 'w+');

if ($fp === false) {
$this->fail('could not open file ' . $file);
}

fseek($fp, File::MAX_FILE_SIZE + 1,SEEK_CUR);
fwrite($fp,'a');
fclose($fp);
Expand All @@ -55,7 +60,7 @@ public function testUploadToBig()
unlink($file);
}

public function testUpload()
public function testUpload(): void
{
$stub = $this->createClientMockObject(
File::class,
Expand All @@ -64,7 +69,12 @@ public function testUpload()

$this->createCacheDir();
$file = $this->getCacheDir() . '/somefile2.jpg';
$fp = fopen($file, 'w+'); //
$fp = fopen($file, 'w+');

if ($fp === false) {
$this->fail('could not open file ' . $file);
}

fseek($fp, 5,SEEK_CUR);
fwrite($fp,'a');
fclose($fp);
Expand Down
8 changes: 4 additions & 4 deletions tests/Clients/InvoiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class InvoiceTest extends TestClient
{

public function testCreate()
public function testCreate(): void
{
$stub = $this->createClientMockObject(
Invoice::class,
Expand All @@ -23,7 +23,7 @@ public function testCreate()
$this->assertEquals('body', $response->getBody()->__toString());
}

public function testGet()
public function testGet(): void
{
$stub = $this->createClientMockObject(
Invoice::class,
Expand All @@ -35,7 +35,7 @@ public function testGet()
$this->assertEquals('body', $response->getBody()->__toString());
}

public function testGetAll()
public function testGetAll(): void
{
$stub = $this->createClientMockObject(
Invoice::class,
Expand All @@ -47,7 +47,7 @@ public function testGetAll()
$this->assertEquals('{"content": [], "totalPages": 1}', $response->getBody()->__toString());
}

public function testDocument()
public function testDocument(): void
{
$stub = $this->createClientMockObject(
Invoice::class,
Expand Down
8 changes: 4 additions & 4 deletions tests/Clients/OrderConfirmationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class OrderConfirmationTest extends TestClient
{

public function testCreate()
public function testCreate(): void
{
$stub = $this->createClientMockObject(
OrderConfirmation::class,
Expand All @@ -23,7 +23,7 @@ public function testCreate()
$this->assertEquals('body', $response->getBody()->__toString());
}

public function testGet()
public function testGet(): void
{
$stub = $this->createClientMockObject(
OrderConfirmation::class,
Expand All @@ -35,7 +35,7 @@ public function testGet()
$this->assertEquals('body', $response->getBody()->__toString());
}

public function testGetAll()
public function testGetAll(): void
{
$stub = $this->createClientMockObject(
OrderConfirmation::class,
Expand All @@ -47,7 +47,7 @@ public function testGetAll()
$this->assertEquals('{"content": [], "totalPages": 1}', $response->getBody()->__toString());
}

public function testDocument()
public function testDocument(): void
{
$stub = $this->createClientMockObject(
OrderConfirmation::class,
Expand Down
2 changes: 1 addition & 1 deletion tests/Clients/PaymentConditionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class PaymentConditionTest extends TestClient
{
public function testGetAll()
public function testGetAll(): void
{
$stub = $this->createClientMockObject(
PaymentCondition::class,
Expand Down
2 changes: 1 addition & 1 deletion tests/Clients/PaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class PaymentTest extends TestClient
{
public function testGet()
public function testGet(): void
{
$stub = $this->createClientMockObject(
Payment::class,
Expand Down
2 changes: 1 addition & 1 deletion tests/Clients/ProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class ProfileTest extends TestClient
{
public function testGet()
public function testGet(): void
{
$stub = $this->createClientMockObject(
Profile::class,
Expand Down
8 changes: 4 additions & 4 deletions tests/Clients/QuotationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class QuotationTest extends TestClient
{

public function testCreate()
public function testCreate(): void
{
$stub = $this->createClientMockObject(
Quotation::class,
Expand All @@ -23,7 +23,7 @@ public function testCreate()
$this->assertEquals('body', $response->getBody()->__toString());
}

public function testGet()
public function testGet(): void
{
$stub = $this->createClientMockObject(
Quotation::class,
Expand All @@ -35,7 +35,7 @@ public function testGet()
$this->assertEquals('body', $response->getBody()->__toString());
}

public function testGetAll()
public function testGetAll(): void
{
$stub = $this->createClientMockObject(
Quotation::class,
Expand All @@ -47,7 +47,7 @@ public function testGetAll()
$this->assertEquals('{"content": [], "totalPages": 1}', $response->getBody()->__toString());
}

public function testDocument()
public function testDocument(): void
{
$stub = $this->createClientMockObject(
Quotation::class,
Expand Down
2 changes: 1 addition & 1 deletion tests/Clients/VoucherListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class VoucherListTest extends TestClient
{

public function testGenerateUrl()
public function testGenerateUrl(): void
{
$stub = $this->createClientMockObject(
VoucherList::class,
Expand Down
Loading

0 comments on commit 36fe494

Please sign in to comment.