Skip to content

Commit

Permalink
Added AsyncHttpConnector clone test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilge committed Jan 9, 2021
1 parent ed0ffa2 commit c49fe63
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/Unit/AsyncHttpConnectorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);

namespace ScriptFUSIONTest\Unit;

use ScriptFUSION\Porter\Net\Http\AsyncHttpConnector;
use PHPUnit\Framework\TestCase;

/**
* @see AsyncHttpConnector
*/
final class AsyncHttpConnectorTest extends TestCase
{
/**
* Tests that when the connector is cloned, all properties are cloned except the pool.
*/
public function testClone(): void
{
$connector = new AsyncHttpConnector();
$newConnector = clone $connector;

self::assertNotSame($connector->getOptions(), $newConnector->getOptions(), 'Options cloned.');
self::assertNotSame($connector->getCookieJar(), $newConnector->getCookieJar(), 'Cookie jar cloned.');

$poolProperty = new \ReflectionProperty(AsyncHttpConnector::class, 'pool');
$poolProperty->setAccessible(true);

self::assertSame(
$poolProperty->getValue($connector),
$poolProperty->getValue($newConnector),
'Pool not cloned.'
);
}
}

0 comments on commit c49fe63

Please sign in to comment.