public function HttpFetcherTest::setUp in Feeds 8.3
Same name in this branch
- 8.3 tests/src/Functional/Feeds/Fetcher/HttpFetcherTest.php \Drupal\Tests\feeds\Functional\Feeds\Fetcher\HttpFetcherTest::setUp()
- 8.3 tests/src/Unit/Feeds/Fetcher/HttpFetcherTest.php \Drupal\Tests\feeds\Unit\Feeds\Fetcher\HttpFetcherTest::setUp()
Overrides FeedsUnitTestCase::setUp
File
- tests/
src/ Unit/ Feeds/ Fetcher/ HttpFetcherTest.php, line 52
Class
- HttpFetcherTest
- @coversDefaultClass \Drupal\feeds\Feeds\Fetcher\HttpFetcher @group feeds
Namespace
Drupal\Tests\feeds\Unit\Feeds\FetcherCode
public function setUp() {
parent::setUp();
$feed_type = $this
->createMock(FeedTypeInterface::class);
$this->mockHandler = new MockHandler();
$client = new Client([
'handler' => HandlerStack::create($this->mockHandler),
]);
$cache = $this
->createMock(CacheBackendInterface::class);
$file_system = $this
->prophesize(FileSystemInterface::class);
$file_system
->tempnam(Argument::type('string'), Argument::type('string'))
->will(function ($args) {
// We suppress any notices as since PHP 7.1, this results into a warning
// when the temporary directory is not configured in php.ini. We are not
// interested in that artefact for this test.
return @tempnam($args[0], $args[1]);
});
$file_system
->realpath(Argument::type('string'))
->will(function ($args) {
return realpath($args[0]);
});
$this->fetcher = new HttpFetcher([
'feed_type' => $feed_type,
], 'http', [], $client, $cache, $file_system
->reveal());
$this->fetcher
->setStringTranslation($this
->getStringTranslationStub());
$this->feed = $this
->prophesize(FeedInterface::class);
$this->feed
->id()
->willReturn(1);
$this->feed
->getSource()
->willReturn('http://example.com');
}