Skip to content
Merged
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
25 changes: 25 additions & 0 deletions tests/system/Publisher/PublisherInputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@

namespace CodeIgniter\Publisher;

use CodeIgniter\HTTP\CURLRequest;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Test\CIUnitTestCase;
use Config\Services;
use PHPUnit\Framework\Attributes\Group;

/**
Expand Down Expand Up @@ -136,16 +139,37 @@ public function testAddPathsRecursive(): void

public function testAddUri(): void
{
$mockCurl = $this->getMockBuilder(CURLRequest::class)
->disableOriginalConstructor()
->onlyMethods(['get'])
->getMock();
$mockResponse = $this->createStub(ResponseInterface::class);

$mockResponse->method('getBody')->willReturn('');
$mockCurl->method('get')->willReturn($mockResponse);
Services::injectMock('curlrequest', $mockCurl);

$publisher = new Publisher();
$publisher->addUri('https://raw.githubusercontent.com/codeigniter4/CodeIgniter4/develop/composer.json');

$scratch = $this->getPrivateProperty($publisher, 'scratch');

$this->assertSame([$scratch . 'composer.json'], $publisher->get());
Services::resetSingle('curlrequest');
}

public function testAddUris(): void
{
$mockCurl = $this->getMockBuilder(CURLRequest::class)
->disableOriginalConstructor()
->onlyMethods(['get'])
->getMock();
$mockResponse = $this->createStub(ResponseInterface::class);

$mockResponse->method('getBody')->willReturn('');
$mockCurl->method('get')->willReturn($mockResponse);
Services::injectMock('curlrequest', $mockCurl);

$publisher = new Publisher();
$publisher->addUris([
'https://raw.githubusercontent.com/codeigniter4/CodeIgniter4/develop/LICENSE',
Expand All @@ -155,5 +179,6 @@ public function testAddUris(): void
$scratch = $this->getPrivateProperty($publisher, 'scratch');

$this->assertSame([$scratch . 'LICENSE', $scratch . 'composer.json'], $publisher->get());
Services::resetSingle('curlrequest');
}
}
Loading