ffmpeg-mappable-media/tests/FFMpeg/Unit/FFProbe/DataMapping/StreamCollectionTest.php

90 lines
2.6 KiB
PHP
Raw Normal View History

2013-06-25 10:03:20 +02:00
<?php
namespace Tests\FFMpeg\Unit\FFProbe\DataMapping;
2013-06-25 10:03:20 +02:00
use FFMpeg\FFProbe\DataMapping\StreamCollection;
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();
$this->assertEquals([], $collection->all());
2013-06-25 10:03:20 +02:00
$collection->add($stream);
$this->assertEquals([$stream], $collection->all());
2013-06-25 10:03:20 +02:00
$collection->add($stream);
$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));
$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);
$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));
$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);
$this->assertEquals([$audio], $audios->all());
2013-06-25 10:03:20 +02:00
}
public function testCount()
{
$stream = $this->getStreamMock();
$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();
$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();
$coll = new StreamCollection([$stream1, $stream2]);
2013-06-25 10:03:20 +02:00
$this->assertSame($stream1, $coll->first());
}
}