Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tiktok #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
50 changes: 50 additions & 0 deletions src/Document/Components/Tiktok.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/**
* @file
* An Apple News Document Tiktok Post.
*/

namespace ChapterThree\AppleNewsAPI\Document\Components;

/**
* An Apple News Document Tiktok Post.
*/
class Tiktok extends Component {

protected $URL;

/**
* Implements __construct().
*
* @param string $url
* Role.
* @param mixed $identifier
* Identifier.
*/
public function __construct($url, $identifier = NULL) {
parent::__construct('tiktok', $identifier);
$this->setUrl($url);
}

/**
* Getter for url.
*/
public function getUrl() {
return $this->URL;
}

/**
* Setter for url.
*
* @param mixed $value
* Url.
*
* @return $this
*/
public function setUrl($value) {
$this->URL = $value;
return $this;
}

}
28 changes: 28 additions & 0 deletions tests/Document/Components/TiktokTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/**
* @file
* Tests for ChapterThree\AppleNewsAPI\Document\Components\Tiktok.
*/

use ChapterThree\AppleNewsAPI\Document\Components\Tiktok;

/**
* Tests for the Tiktok class.
*/
class TiktokTest extends PHPUnit_Framework_TestCase {

/**
* Setting properties and outputting json.
*/
public function testSetters() {

$obj = new Tiktok('https://www.tiktok.com/@applemusic/video/6564018881122276367');

// Optional properties.
$expected = '{"role":"tiktok","URL":"https://www.tiktok.com/@applemusic/video/6564018881122276367"}';
$this->assertJsonStringEqualsJsonString($expected, $obj->json());

}

}