-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from samuelhgf/master
Implements a method that returns only the built link of the social network
- Loading branch information
Showing
3 changed files
with
185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?php | ||
|
||
|
||
namespace Jorenvh\Share\Test; | ||
|
||
|
||
use Jorenvh\Share\ShareFacade; | ||
|
||
class RawLinksTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function it_can_return_only_facebook_built_link() | ||
{ | ||
$expected = 'https://www.facebook.com/sharer/sharer.php?u=https://codeswitch.be'; | ||
$result = ShareFacade::page('https://codeswitch.be', 'My share title') | ||
->facebook() | ||
->getRawLinks(); | ||
|
||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_return_only_twitter_built_link() | ||
{ | ||
$expected = 'https://twitter.com/intent/tweet?text=My+share+title&url=https://codeswitch.be'; | ||
$result = ShareFacade::page('https://codeswitch.be', 'My share title') | ||
->twitter() | ||
->getRawLinks(); | ||
|
||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_return_only_linkedin_built_link() | ||
{ | ||
$expected = 'http://www.linkedin.com/shareArticle?mini=true&url=https://codeswitch.be&title=My+share+title&summary='; | ||
$result = ShareFacade::page('https://codeswitch.be', 'My share title') | ||
->linkedin() | ||
->getRawLinks(); | ||
|
||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_return_only_whatsapp_built_link() | ||
{ | ||
$expected = 'https://wa.me/?text=https://codeswitch.be'; | ||
$result = ShareFacade::page('https://codeswitch.be', 'My share title') | ||
->whatsapp() | ||
->getRawLinks(); | ||
|
||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_return_only_pinterest_built_link() | ||
{ | ||
$expected = 'http://pinterest.com/pin/create/button/?url=https://codeswitch.be'; | ||
$result = ShareFacade::page('https://codeswitch.be', 'My share title') | ||
->pinterest() | ||
->getRawLinks(); | ||
|
||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_return_only_reddit_built_link() | ||
{ | ||
$expected = 'https://www.reddit.com/submit?title=My+share+title&url=https://codeswitch.be'; | ||
$result = ShareFacade::page('https://codeswitch.be', 'My share title') | ||
->reddit() | ||
->getRawLinks(); | ||
|
||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_return_only_telegram_built_link() | ||
{ | ||
$expected = 'https://telegram.me/share/url?url=https://codeswitch.be&text=My+share+title'; | ||
$result = ShareFacade::page('https://codeswitch.be', 'My share title') | ||
->telegram() | ||
->getRawLinks(); | ||
|
||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_return_multiple_built_links_at_once() | ||
{ | ||
$result = ShareFacade::page('https://codeswitch.be', 'My share title') | ||
->facebook() | ||
->twitter() | ||
->linkedin() | ||
->whatsapp() | ||
->pinterest() | ||
->reddit() | ||
->telegram() | ||
->getRawLinks(); | ||
|
||
$expected = [ | ||
'facebook' => 'https://www.facebook.com/sharer/sharer.php?u=https://codeswitch.be', | ||
'twitter' => 'https://twitter.com/intent/tweet?text=My+share+title&url=https://codeswitch.be', | ||
'linkedin' => 'http://www.linkedin.com/shareArticle?mini=true&url=https://codeswitch.be&title=My+share+title&summary=', | ||
'whatsapp' => 'https://wa.me/?text=https://codeswitch.be', | ||
'pinterest' => 'http://pinterest.com/pin/create/button/?url=https://codeswitch.be', | ||
'reddit' => 'https://www.reddit.com/submit?title=My+share+title&url=https://codeswitch.be', | ||
'telegram' => 'https://telegram.me/share/url?url=https://codeswitch.be&text=My+share+title', | ||
]; | ||
|
||
$this->assertEquals($expected, $result); | ||
} | ||
} |