| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- <?php
- /**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Feed
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id$
- */
- require_once 'Zend/Feed/Writer/Entry.php';
- /**
- * @category Zend
- * @package Zend_Feed
- * @subpackage UnitTests
- * @group Zend_Feed
- * @group Zend_Feed_Writer
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
- class Zend_Feed_Writer_Extension_ITunes_EntryTest extends PHPUnit_Framework_TestCase
- {
- public function testSetBlock()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->setItunesBlock('yes');
- $this->assertEquals('yes', $entry->getItunesBlock());
- }
- /**
- * @expectedException Zend_Feed_Exception
- */
- public function testSetBlockThrowsExceptionOnNonAlphaValue()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->setItunesBlock('123');
- }
- /**
- * @expectedException Zend_Feed_Exception
- */
- public function testSetBlockThrowsExceptionIfValueGreaterThan255CharsLength()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->setItunesBlock(str_repeat('a', 256));
- }
- public function testAddAuthors()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->addItunesAuthors(array('joe', 'jane'));
- $this->assertEquals(array('joe', 'jane'), $entry->getItunesAuthors());
- }
- public function testAddAuthor()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->addItunesAuthor('joe');
- $this->assertEquals(array('joe'), $entry->getItunesAuthors());
- }
- /**
- * @expectedException Zend_Feed_Exception
- */
- public function testAddAuthorThrowsExceptionIfValueGreaterThan255CharsLength()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->addItunesAuthor(str_repeat('a', 256));
- }
- public function testSetDurationAsSeconds()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->setItunesDuration(23);
- $this->assertEquals(23, $entry->getItunesDuration());
- }
- public function testSetDurationAsMinutesAndSeconds()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->setItunesDuration('23:23');
- $this->assertEquals('23:23', $entry->getItunesDuration());
- }
- public function testSetDurationAsHoursMinutesAndSeconds()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->setItunesDuration('23:23:23');
- $this->assertEquals('23:23:23', $entry->getItunesDuration());
- }
- /**
- * @expectedException Zend_Feed_Exception
- */
- public function testSetDurationThrowsExceptionOnUnknownFormat()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->setItunesDuration('abc');
- }
- /**
- * @expectedException Zend_Feed_Exception
- */
- public function testSetDurationThrowsExceptionOnInvalidSeconds()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->setItunesDuration('23:456');
- }
- /**
- * @expectedException Zend_Feed_Exception
- */
- public function testSetDurationThrowsExceptionOnInvalidMinutes()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->setItunesDuration('23:234:45');
- }
- public function testSetExplicitToYes()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->setItunesExplicit('yes');
- $this->assertEquals('yes', $entry->getItunesExplicit());
- }
- public function testSetExplicitToNo()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->setItunesExplicit('no');
- $this->assertEquals('no', $entry->getItunesExplicit());
- }
- public function testSetExplicitToClean()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->setItunesExplicit('clean');
- $this->assertEquals('clean', $entry->getItunesExplicit());
- }
- /**
- * @expectedException Zend_Feed_Exception
- */
- public function testSetExplicitThrowsExceptionOnUnknownTerm()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->setItunesExplicit('abc');
- }
- public function testSetKeywords()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $words = array(
- 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'a10', 'a11', 'a12'
- );
- $entry->setItunesKeywords($words);
- $this->assertEquals($words, $entry->getItunesKeywords());
- }
- /**
- * @expectedException Zend_Feed_Exception
- */
- public function testSetKeywordsThrowsExceptionIfMaxKeywordsExceeded()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $words = array(
- 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'a10', 'a11', 'a12', 'a13'
- );
- $entry->setItunesKeywords($words);
- }
- /**
- * @expectedException Zend_Feed_Exception
- */
- public function testSetKeywordsThrowsExceptionIfFormattedKeywordsExceeds255CharLength()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $words = array(
- str_repeat('a', 253), str_repeat('b', 2)
- );
- $entry->setItunesKeywords($words);
- }
- public function testSetSubtitle()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->setItunesSubtitle('abc');
- $this->assertEquals('abc', $entry->getItunesSubtitle());
- }
- /**
- * @expectedException Zend_Feed_Exception
- */
- public function testSetSubtitleThrowsExceptionWhenValueExceeds255Chars()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->setItunesSubtitle(str_repeat('a', 256));
- }
- public function testSetSummary()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->setItunesSummary('abc');
- $this->assertEquals('abc', $entry->getItunesSummary());
- }
- /**
- * @expectedException Zend_Feed_Exception
- */
- public function testSetSummaryThrowsExceptionWhenValueExceeds255Chars()
- {
- $entry = new Zend_Feed_Writer_Entry;
- $entry->setItunesSummary(str_repeat('a', 4001));
- }
- }
|