2013-06-25 10:03:20 +02:00
|
|
|
<?php
|
|
|
|
|
|
2016-03-06 23:38:04 +01:00
|
|
|
namespace Tests\FFMpeg\Unit\FFProbe\DataMapping;
|
2013-06-25 10:03:20 +02:00
|
|
|
|
|
|
|
|
use FFMpeg\FFProbe\DataMapping\StreamCollection;
|
2022-02-09 14:32:43 +01:00
|
|
|
use Tests\FFMpeg\Unit\TestCase;
|
2013-06-25 10:03:20 +02:00
|
|
|
|
|
|
|
|
class StreamCollectionTest extends TestCase
|
|
|
|
|
{
|
|
|
|
|
public function testAdd()
|
|
|
|
|
{
|
|
|
|
|
$stream = $this->getStreamMock();
|
|
|
|
|
|
|
|
|
|
$collection = new StreamCollection();
|
2022-02-09 14:32:43 +01:00
|
|
|
$this->assertEquals([], $collection->all());
|
2013-06-25 10:03:20 +02:00
|
|
|
$collection->add($stream);
|
2022-02-09 14:32:43 +01:00
|
|
|
$this->assertEquals([$stream], $collection->all());
|
2013-06-25 10:03:20 +02:00
|
|
|
$collection->add($stream);
|
2022-02-09 14:32:43 +01:00
|
|
|
$this->assertEquals([$stream, $stream], $collection->all());
|
2013-06-25 10:03:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testVideos()
|
|
|
|
|
{
|
|
|
|
|
$audio = $this->getStreamMock();
|
|
|
|
|
$audio->expects($this->once())
|
|
|
|
|
->method('isVideo')
|
|
|
|
|
->will($this->returnValue(false));
|
|
|
|
|
|
|
|
|
|
$video = $this->getStreamMock();
|
|
|
|
|
$video->expects($this->once())
|
|
|
|
|
->method('isVideo')
|
|
|
|
|
->will($this->returnValue(true));
|
|
|
|
|
|
2022-02-09 14:32:43 +01:00
|
|
|
$collection = new StreamCollection([$audio, $video]);
|
2013-06-25 10:03:20 +02:00
|
|
|
$videos = $collection->videos();
|
|
|
|
|
|
|
|
|
|
$this->assertInstanceOf('FFMpeg\FFProbe\DataMapping\StreamCollection', $videos);
|
|
|
|
|
$this->assertCount(1, $videos);
|
2022-02-09 14:32:43 +01:00
|
|
|
$this->assertEquals([$video], $videos->all());
|
2013-06-25 10:03:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testAudios()
|
|
|
|
|
{
|
|
|
|
|
$audio = $this->getStreamMock();
|
|
|
|
|
$audio->expects($this->once())
|
|
|
|
|
->method('isAudio')
|
|
|
|
|
->will($this->returnValue(true));
|
|
|
|
|
|
|
|
|
|
$video = $this->getStreamMock();
|
|
|
|
|
$video->expects($this->once())
|
|
|
|
|
->method('isAudio')
|
|
|
|
|
->will($this->returnValue(false));
|
|
|
|
|
|
2022-02-09 14:32:43 +01:00
|
|
|
$collection = new StreamCollection([$audio, $video]);
|
2013-06-25 10:03:20 +02:00
|
|
|
$audios = $collection->audios();
|
|
|
|
|
|
|
|
|
|
$this->assertInstanceOf('FFMpeg\FFProbe\DataMapping\StreamCollection', $audios);
|
|
|
|
|
$this->assertCount(1, $audios);
|
2022-02-09 14:32:43 +01:00
|
|
|
$this->assertEquals([$audio], $audios->all());
|
2013-06-25 10:03:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testCount()
|
|
|
|
|
{
|
|
|
|
|
$stream = $this->getStreamMock();
|
|
|
|
|
|
2022-02-09 14:32:43 +01:00
|
|
|
$collection = new StreamCollection([$stream]);
|
2013-06-25 10:03:20 +02:00
|
|
|
$this->assertCount(1, $collection);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetIterator()
|
|
|
|
|
{
|
|
|
|
|
$audio = $this->getStreamMock();
|
|
|
|
|
$video = $this->getStreamMock();
|
|
|
|
|
|
2022-02-09 14:32:43 +01:00
|
|
|
$collection = new StreamCollection([$audio, $video]);
|
2013-06-25 10:03:20 +02:00
|
|
|
$this->assertInstanceOf('\Iterator', $collection->getIterator());
|
|
|
|
|
$this->assertCount(2, $collection->getIterator());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testFirst()
|
|
|
|
|
{
|
|
|
|
|
$stream1 = $this->getStreamMock();
|
|
|
|
|
$stream2 = $this->getStreamMock();
|
|
|
|
|
|
2022-02-09 14:32:43 +01:00
|
|
|
$coll = new StreamCollection([$stream1, $stream2]);
|
2013-06-25 10:03:20 +02:00
|
|
|
|
|
|
|
|
$this->assertSame($stream1, $coll->first());
|
|
|
|
|
}
|
|
|
|
|
}
|