| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <?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_Tool
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id$
- */
- /**
- * @see Zend_Tool_Framework_Action_Base
- */
- require_once 'Zend/Tool/Framework/Manifest/Metadata.php';
- /**
- * @category Zend
- * @package Zend_Tool
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- *
- * @group Zend_Tool
- * @group Zend_Tool_Framework
- * @group Zend_Tool_Framework_Manifest
- */
- class Zend_Tool_Framework_Manifest_MetadataTest extends PHPUnit_Framework_TestCase
- {
- /**
- * @var Zend_Tool_Framework_Manifest_Metadata
- */
- protected $_metadata = null;
- public function setup()
- {
- $this->_metadata = new Zend_Tool_Framework_Manifest_Metadata();
- }
- public function teardown()
- {
- $this->_metadata = null;
- }
- public function testConstructorWillAcceptAndPersistValues()
- {
- $obj1 = new ArrayObject();
- $metadata = new Zend_Tool_Framework_Manifest_Metadata(array(
- 'name' => 'Foo',
- 'value' => 'Bar',
- 'reference' => $obj1
- ));
- $this->assertEquals('Foo', $metadata->getName());
- $this->assertEquals('Bar', $metadata->getValue());
- $this->assertTrue($obj1 === $metadata->getReference());
- }
- public function testSetOptionsPersistValues()
- {
- $obj1 = new ArrayObject();
- $this->_metadata->setOptions(array(
- 'name' => 'Foo',
- 'value' => 'Bar',
- 'reference' => $obj1
- ));
- $this->assertEquals('Foo', $this->_metadata->getName());
- $this->assertEquals('Bar', $this->_metadata->getValue());
- $this->assertTrue($obj1 === $this->_metadata->getReference());
- }
- public function testGetTypeHasDefaultValue()
- {
- $this->assertEquals('Global', $this->_metadata->getType());
- }
- public function testTypeIsModifiable()
- {
- $this->_metadata->setType('foo');
- $this->assertEquals('foo', $this->_metadata->getType());
- }
- public function testSettersPersistValuesAndAreRetievableThroughGetters()
- {
- $this->_metadata->setName('Foo');
- $this->assertEquals('Foo', $this->_metadata->getName());
- $this->_metadata->setValue('Bar');
- $this->assertEquals('Bar', $this->_metadata->getValue());
- }
- public function testGetAttributesReturnsProperValues()
- {
- $obj1 = new ArrayObject();
- $this->_metadata->setOptions(array(
- 'name' => 'Foo',
- 'value' => null,
- 'reference' => $obj1
- ));
- $attributes = $this->_metadata->getAttributes();
- $this->assertEquals(4, count($attributes));
- $this->assertEquals('Global', $attributes['type']);
- $this->assertEquals('Foo', $attributes['name']);
- $this->assertEquals(null, $attributes['value']);
- $this->assertTrue($obj1 === $attributes['reference']);
- $attributes = $this->_metadata->getAttributes(Zend_Tool_Framework_Manifest_Metadata::ATTRIBUTES_NO_PARENT);
- $this->assertEquals(0, count($attributes));
- $attributes = $this->_metadata->getAttributes(Zend_Tool_Framework_Manifest_Metadata::ATTRIBUTES_ALL, true);
- $this->assertEquals(4, count($attributes));
- $this->assertEquals('Global', $attributes['type']);
- $this->assertEquals('Foo', $attributes['name']);
- $this->assertEquals('(null)', $attributes['value']);
- $this->assertEquals('(object)', $attributes['reference']);
- }
- public function testMetadataObjectCanCastToStringRepresentation()
- {
- $obj1 = new ArrayObject();
- $this->_metadata->setOptions(array(
- 'name' => 'Foo',
- 'value' => 'Bar',
- 'reference' => $obj1
- ));
- $this->assertEquals('Type: Global, Name: Foo, Value: Bar', (string) $this->_metadata);
- }
- }
|