Exemplo n.º 1
0
 /**
  * @param (string|(string|callable|string[])[])[]|null $whitelist
  * @param string $input
  * @param string $output
  * @param string[][] $logs
  * @param mixed[] $options
  * @dataProvider dataProvider
  */
 public function testFilter($whitelist, string $input, string $output, array $logs, array $options = [])
 {
     $filter = new Filter($whitelist, $options);
     $filter->setLogger($this);
     $result = $filter->filter($input);
     $this->assertEquals($logs, $this->logs);
     $this->assertSame($output, $result);
 }
 /**
  * HTMLフィルターを生成します。
  * @return HTMLFilter
  */
 protected function createHTMLFilter() : HTMLFilter
 {
     if ($this->source) {
         $whitelist = self::SOURCE_WHITELIST;
     } else {
         $whitelist = self::DESCRIPTION_WHITELIST;
         $whitelist['audio']['src'] = [$this, 'validateAudioLocation'];
         $whitelist['img']['src'] = [$this, 'validateImageLocation'];
         $whitelist['video']['src'] = [$this, 'validateVideoLocation'];
     }
     $filter = new \esperecyan\html_filter\Filter($whitelist);
     $filter->setLogger($this);
     return $filter;
 }