Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 0 additions & 85 deletions tests/src/Unit/Adapter/Psr7/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,6 @@ protected function setUp(): void
);
}

public function testGetStatusCode(): void
{
$this->assertEquals(200, $this->response->getStatusCode());
}

public function testWithStatus(): void
{
$withStatus = $this->response->withStatus(404, 'Not Found');
$this->assertEquals(404, $withStatus->getStatusCode());
$this->assertEquals('Not Found', $withStatus->getReasonPhrase());
}

public function testGetReasonPhrase(): void
{
$this->assertEquals('OK', $this->response->getReasonPhrase());
}

public function testGetHarResponse(): void
{
$harResponse = $this->response->getHarResponse();
$this->assertInstanceOf(\Deviantintegral\Har\Response::class, $harResponse);
$this->assertEquals(200, $harResponse->getStatus());
}

public function testWithHeader(): void
{
$withHeader = $this->response->withHeader('X-Test', 'value');
Expand Down Expand Up @@ -78,29 +54,6 @@ public function testGetHeaderLineWhenHeaderNotPresent(): void
$this->assertEquals('', $this->response->getHeaderLine('X-NonExistent'));
}

public function testGetHeader(): void
{
$headers = $this->response->getHeader('Content-Type');
$this->assertEquals(['text/html; charset=UTF-8'], $headers);
}

public function testHasHeader(): void
{
$this->assertTrue($this->response->hasHeader('Content-Type'));
$this->assertFalse($this->response->hasHeader('X-NonExistent'));
}

public function testGetHeaders(): void
{
$headers = $this->response->getHeaders();
$this->assertArrayHasKey('Content-Type', $headers);
}

public function testGetProtocolVersion(): void
{
$this->assertEquals('1.1', $this->response->getProtocolVersion());
}

public function testWithProtocolVersion(): void
{
$withProtocol = $this->response->withProtocolVersion('2.0');
Expand All @@ -113,44 +66,6 @@ public function testWithoutHeader(): void
$this->assertFalse($withoutHeader->hasHeader('Content-Type'));
}

public function testWithAddedHeader(): void
{
$withAdded = $this->response->withAddedHeader('X-Custom', 'value1');
$this->assertEquals(['value1'], $withAdded->getHeader('X-Custom'));

$withMultiple = $withAdded->withAddedHeader('X-Custom', 'value2');
$this->assertEquals(['value1', 'value2'], $withMultiple->getHeader('X-Custom'));
}

public function testWithAddedHeaderArrayValue(): void
{
$withAdded = $this->response->withAddedHeader('X-Custom', ['value1', 'value2']);
$this->assertEquals(['value1', 'value2'], $withAdded->getHeader('X-Custom'));
}

public function testGetBody(): void
{
$body = $this->response->getBody();
$this->assertInstanceOf(\Psr\Http\Message\StreamInterface::class, $body);

// Verify the body content matches the response content
$bodyContent = $body->getContents();
$this->assertNotEmpty($bodyContent);
}

public function testWithBody(): void
{
$newBodyContent = 'Test body content';
$newBody = \GuzzleHttp\Psr7\Utils::streamFor($newBodyContent);

$withBody = $this->response->withBody($newBody);
$this->assertInstanceOf(Response::class, $withBody);

// Verify the new body content
$resultBody = $withBody->getBody();
$this->assertEquals($newBodyContent, $resultBody->getContents());
}

public function testWithStatusDoesNotModifyOriginal(): void
{
$original = $this->response;
Expand Down
1 change: 0 additions & 1 deletion tests/src/Unit/Adapter/Psr7/ServerRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ public function testGetAttributes(): void
public function testGetAttribute(): void
{
// Attributes are not part of HAR spec, always returns default
$this->assertNull($this->serverRequest->getAttribute('custom_attr'));
$this->assertNull($this->serverRequest->getAttribute('nonexistent'));
$this->assertEquals('default', $this->serverRequest->getAttribute('nonexistent', 'default'));
}
Expand Down
73 changes: 0 additions & 73 deletions tests/src/Unit/BrowserTest.php

This file was deleted.

7 changes: 0 additions & 7 deletions tests/src/Unit/CookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ public function testSerialize(): void
->setSecure(true)
->setValue('Test value');

$this->assertTrue($cookie->hasSecure());
$this->assertNotNull($cookie->isSecure());
$this->assertTrue($cookie->hasHttpOnly());
$this->assertNotNull($cookie->isHttpOnly());

$serialized = $serializer->serialize($cookie, 'json');
$this->assertEquals(
[
Expand Down Expand Up @@ -62,9 +57,7 @@ public function testSerializeWithoutOptionalAttributes(): void
->setValue('Test value');

$this->assertFalse($cookie->hasSecure());
$this->assertNull($cookie->isSecure());
$this->assertFalse($cookie->hasHttpOnly());
$this->assertNull($cookie->isHttpOnly());

$serialized = $serializer->serialize($cookie, 'json');
$this->assertEquals(
Expand Down
18 changes: 0 additions & 18 deletions tests/src/Unit/EntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,6 @@ public function testHasInitiator(): void
$this->assertTrue($first->hasInitiator());
}

public function testSerializationOfEntryWithAddedInitiatorOfTypeOther(): void
{
// Load a HAR file into an object.
$id = 'www.softwareishard.com-empty-login.har';
$har = $this->repository->load($id);
$first = $har->getLog()->getEntries()[0];
$first->setInitiator((new Initiator())->setType('other'));

$serialized = $this->getSerializer()->serialize($har, 'json');
$actual = json_decode($serialized, true);
$this->assertIsArray($actual['log']['entries'][0]['_initiator']);
$this->assertEquals('other', $actual['log']['entries'][0]['_initiator']['type']);
$this->assertArrayNotHasKey('url', $actual['log']['entries'][0]['_initiator']);
$this->assertArrayNotHasKey('lineNumber', $actual['log']['entries'][0]['_initiator']);

$this->assertArrayNotHasKey('_initiator', $actual['log']['entries'][1]);
}

public function testGetSetPageref(): void
{
$entry = (new Entry())->setPageref('page_1');
Expand Down
34 changes: 0 additions & 34 deletions tests/src/Unit/HeaderTest.php

This file was deleted.

4 changes: 0 additions & 4 deletions tests/src/Unit/InitiatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public function testInitiatorWithTypeOther(): void

$this->assertDeserialize($serialized, Initiator::class, $initiator);

$this->assertFalse($initiator->hasUrl());
$this->assertNull($initiator->getUrl());
$this->assertFalse($initiator->hasLineNumber());
$this->assertNull($initiator->getLineNumber());
}

Expand All @@ -55,8 +53,6 @@ public function testInitiatorWithTypeParser(): void
$initiator->setUrl(new Uri('https://www.php.net/'));
$this->assertDeserialize($serialized, Initiator::class, $initiator);
$this->assertTrue($initiator->hasLineNumber());
$this->assertIsNumeric($initiator->getLineNumber());
$this->assertTrue($initiator->hasUrl());
$this->assertNotNull($initiator->getUrl());
}
}
33 changes: 0 additions & 33 deletions tests/src/Unit/MissingLogKeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Deviantintegral\Har\Tests\Unit;

use Deviantintegral\Har\Repository\HarFileRepository;
use Deviantintegral\Har\Serializer;
use JMS\Serializer\Exception\RuntimeException;

Expand All @@ -13,38 +12,6 @@
*/
class MissingLogKeyTest extends HarTestBase
{
/**
* Tests that deserializeHar() throws RuntimeException when 'log' key is missing.
*
* Before this fix, the HAR would deserialize successfully but accessing
* the log property would throw an Error about uninitialized property.
* Now, deserializeHar() validates and throws a proper exception immediately.
*/
public function testMissingLogKeyThrowsException(): void
{
$repository = new HarFileRepository(__DIR__.'/../../fixtures/edge-cases');
$serializer = new Serializer();

$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('HAR file must contain a "log" key');

$json = $repository->loadJson('missing-log.har');
$serializer->deserializeHar($json);
}

/**
* Tests that deserializeHar() throws RuntimeException for invalid JSON structure.
*/
public function testEmptyJsonThrowsException(): void
{
$serializer = new Serializer();

$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('HAR file must contain a "log" key');

$serializer->deserializeHar('{}');
}

/**
* Tests that deserializeHar() throws RuntimeException when JSON is not an object.
*/
Expand Down
15 changes: 0 additions & 15 deletions tests/src/Unit/PageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,6 @@ public function testSerialize(): void
],
json_decode($serialized, true)
);

$deserialized = $serializer->deserialize($serialized, Page::class, 'json');
$this->assertEquals($page, $deserialized);
}

public function testGetSetId(): void
{
$page = (new Page())->setId('page_123');
$this->assertEquals('page_123', $page->getId());
}

public function testGetSetTitle(): void
{
$page = (new Page())->setTitle('Test Page Title');
$this->assertEquals('Test Page Title', $page->getTitle());
}

public function testGetSetPageTimings(): void
Expand Down
7 changes: 0 additions & 7 deletions tests/src/Unit/PageTimingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,5 @@ public function testSerialize(): void
],
json_decode($serialized, true)
);

$deserialized = $serializer->deserialize(
$serialized,
PageTimings::class,
'json'
);
$this->assertEquals($creator, $deserialized);
}
}
Loading