public function testRenderWithTitleAndAutoplayMuted()
 {
     $audio = Audio::create()->withURL('http://foo.com/mp3')->withTitle('audio title')->enableMuted()->enableAutoplay();
     $expected = '<audio title="audio title" autoplay="autoplay" muted="muted">' . '<source src="http://foo.com/mp3"/>' . '</audio>';
     $rendered = $audio->render();
     $this->assertEquals($expected, $rendered);
 }
 public function testRenderWithAudio()
 {
     $audio = Audio::create()->withURL('http://foo.com/mp3')->withTitle('audio title')->enableMuted()->enableAutoplay();
     $expected_audio = '<audio title="audio title" autoplay="autoplay" muted="muted">' . '<source src="http://foo.com/mp3"/>' . '</audio>';
     $slideshow = SlideShow::create()->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home.jpg'))->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home2.jpg'))->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home3.jpg'))->withAudio($audio);
     $expected = '<figure class="op-slideshow">' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home.jpg"/>' . '</figure>' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home2.jpg"/>' . '</figure>' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home3.jpg"/>' . '</figure>' . $expected_audio . '</figure>';
     $rendered = $slideshow->render();
     $this->assertEquals($expected, $rendered);
 }
示例#3
0
 /**
  * @param array $attributes
  */
 public function loadRelated(array $attributes)
 {
     parent::loadRelated($attributes);
     if (isset($attributes['from'])) {
         $this->from = User::create($attributes['from']);
     }
     if (isset($attributes['chat'])) {
         $this->chat = isset($attributes['chat']->title) ? GroupChat::create($attributes['chat']) : User::create($attributes['chat']);
     }
     if (isset($attributes['forward_from'])) {
         $this->forward_from = User::create($attributes['forward_from']);
     }
     if (isset($attributes['forward_from_chat'])) {
         $this->forward_from_chat = Chat::create($attributes['forward_from_chat']);
     }
     if (isset($attributes['reply_to_message'])) {
         $this->reply_to_message = Message::create($attributes['reply_to_message']);
     }
     if (isset($attributes['entities'])) {
         $this->entities = array_map(function ($entity) {
             return MessageEntity::create($entity);
         }, $attributes['entities']);
     }
     if (isset($attributes['audio'])) {
         $this->audio = Audio::create($attributes['audio']);
     }
     if (isset($attributes['document'])) {
         $this->document = Document::create($attributes['document']);
     }
     if (isset($attributes['photo'])) {
         $this->photo = array_map(function ($photo) {
             return PhotoSize::create($photo);
         }, $attributes['photo']);
     }
     if (isset($attributes['sticker'])) {
         $this->sticker = Sticker::create($attributes['sticker']);
     }
     if (isset($attributes['video'])) {
         $this->video = Video::create($attributes['video']);
     }
     if (isset($attributes['voice'])) {
         $this->voice = Voice::create($attributes['voice']);
     }
     if (isset($attributes['contact'])) {
         $this->contact = Contact::create($attributes['contact']);
     }
     if (isset($attributes['location'])) {
         $this->location = Location::create($attributes['location']);
     }
     if (isset($attributes['venue'])) {
         $this->venue = Venue::create($attributes['venue']);
     }
     if (isset($attributes['new_chat_member'])) {
         $this->new_chat_member = User::create($attributes['new_chat_member']);
     }
     if (isset($attributes['left_chat_member'])) {
         $this->left_chat_member = new User($attributes['left_chat_member']);
     }
     if (isset($attributes['new_chat_photo'])) {
         $this->new_chat_photo = array_map(function ($photo) {
             return PhotoSize::create($photo);
         }, $attributes['new_chat_photo']);
     }
 }
示例#4
0
文件: Import.php 项目: popfeng/zao
 /**
  * 插入声音记录
  *
  * @param array $group
  * @return void
  */
 protected static function insertAudios(array $group)
 {
     foreach ($group as $data) {
         $list = ['qiniu' => $data, 'other' => $data];
         if (!empty($data['file_name'])) {
             $list['qiniu']['src'] = Audio::SOURCE_DEFAULT;
             $list['qiniu']['url'] = self::getQiniuUrl($data['file_name']);
         }
         if (!empty($data['original_url'])) {
             $list['other']['src'] = $data['url_source'];
             $list['other']['url'] = $data['original_url'];
         } else {
             unset($list['other']);
         }
         foreach ($list as $item) {
             Audio::create(['date' => $item['date'], 'part' => $item['part'], 'title' => $item['topic'], 'source' => $item['src'], 'url' => $item['url'], 'state' => Audio::STATE_ENABLE]);
         }
     }
 }