Beispiel #1
0
 /**
  * @test
  */
 public function itShouldBuildTheObject()
 {
     $delete = TwitterDelete::create($this->type, $this->id, $this->userId, $this->date);
     $this->assertEquals($this->type, $delete->getType());
     $this->assertEquals($this->id, $delete->getId());
     $this->assertEquals($this->userId, $delete->getUserId());
     $this->assertEquals($this->date, $delete->getDate());
     $this->assertEquals('Deleted [' . $this->type . '][' . $this->id . ']', (string) $delete);
 }
 public function setUp()
 {
     $faker = Factory::create();
     $this->id = $faker->randomNumber();
     $this->userId = $faker->randomNumber();
     $this->date = new \DateTimeImmutable();
     $this->deleteDirectMessage = TwitterDelete::create(TwitterDelete::DM, $this->id, $this->userId, $this->date);
     $this->twitterMessage = TwitterDelete::create(TwitterDelete::TWEET, $this->id, $this->userId, $this->date);
     $this->serviceUnderTest = new TwitterDeleteSerializer();
 }
 /**
  * @param  \stdClass $obj
  * @param  array     $context
  * @return TwitterDelete
  */
 public function unserialize($obj, array $context = [])
 {
     Assertion::true($this->canUnserialize($obj), 'object is not unserializable');
     $d = $obj->delete;
     if (isset($d->status)) {
         $ref = $d->status;
         $type = TwitterDelete::TWEET;
     } else {
         $ref = $d->direct_message;
         $type = TwitterDelete::DM;
     }
     return TwitterDelete::create($type, $ref->id, $ref->user_id, (new \DateTimeImmutable())->setTimestamp((int) floor($d->timestamp_ms / 1000)) ?: new \DateTimeImmutable());
 }