mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-04 10:04:54 +02:00
fix(reddit): url encoding (#4010)
This commit is contained in:
parent
5b80af978f
commit
4bad1c140a
3 changed files with 62 additions and 49 deletions
|
@ -157,29 +157,6 @@ class BridgeImplementationTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataBridgesProvider
|
||||
*/
|
||||
public function testVisibleMethods($path)
|
||||
{
|
||||
$bridgeAbstractMethods = get_class_methods(BridgeAbstract::class);
|
||||
sort($bridgeAbstractMethods);
|
||||
$feedExpanderMethods = get_class_methods(FeedExpander::class);
|
||||
sort($feedExpanderMethods);
|
||||
|
||||
$this->setBridge($path);
|
||||
|
||||
$publicMethods = get_class_methods($this->bridge);
|
||||
sort($publicMethods);
|
||||
foreach ($publicMethods as $publicMethod) {
|
||||
if ($this->bridge instanceof FeedExpander) {
|
||||
$this->assertContains($publicMethod, $feedExpanderMethods);
|
||||
} else {
|
||||
$this->assertContains($publicMethod, $bridgeAbstractMethods);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataBridgesProvider
|
||||
*/
|
||||
|
|
33
tests/RedditBridgeTest.php
Normal file
33
tests/RedditBridgeTest.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class RedditBridgeTest extends TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$sut = new RedditBridge(new NullCache(), new NullLogger());
|
||||
|
||||
// https://old.reddit.com/search.json?q=cats dogs hen subreddit:php&sort=hot&include_over_18=on
|
||||
$expected = 'https://old.reddit.com/search.json?q=cats+dogs+hen+subreddit%3Aphp&sort=hot&include_over_18=on';
|
||||
$actual = RedditBridge::createUrl('cats,dogs hen', '', 'php', false, 'hot', 'single');
|
||||
$this->assertSame($expected, $actual);
|
||||
|
||||
// https://old.reddit.com/search.json?q=author:RavenousRandy&sort=hot&include_over_18=on
|
||||
$expected = 'https://old.reddit.com/search.json?q=author%3ARavenousRandy&sort=hot&include_over_18=on';
|
||||
$actual = RedditBridge::createUrl('', '', 'RavenousRandy', true, 'hot', 'user');
|
||||
$this->assertSame($expected, $actual);
|
||||
|
||||
// https://old.reddit.com/search.json?q=cats dogs hen flair:"Proxy" subreddit:php&sort=hot&include_over_18=on
|
||||
$expected = 'https://old.reddit.com/search.json?q=cats+dogs+hen+flair%3A%22Proxy%22+subreddit%3Aphp&sort=hot&include_over_18=on';
|
||||
$actual = RedditBridge::createUrl('cats,dogs hen', 'Proxy', 'php', false, 'hot', 'single');
|
||||
$this->assertSame($expected, $actual);
|
||||
|
||||
// https://old.reddit.com/search.json?q=cats dogs hen flair:"Proxy Linux Server" subreddit:php&sort=hot&include_over_18=on
|
||||
$expected = 'https://old.reddit.com/search.json?q=cats+dogs+hen+flair%3A%22Proxy+Linux+Server%22+subreddit%3Aphp&sort=hot&include_over_18=on';
|
||||
$actual = RedditBridge::createUrl('cats,dogs hen', 'Proxy,Linux Server', 'php', false, 'hot', 'single');
|
||||
$this->assertSame($expected, $actual);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue