Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/view' of https://github.com/sasezaki/zf2 into ho…
Browse files Browse the repository at this point in the history
…tfix/view-zf1-sync
  • Loading branch information
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Helper/Currency.php
Expand Up @@ -61,7 +61,7 @@ public function __construct($currency = null)
* Output a formatted currency
*
* @param integer|float $value Currency value to output
* @param string|\Zend\Locale\Locale|\Zend\Currency\Currency $currency OPTIONAL Currency to use for this call
* @param string|\Zend\Locale\Locale|array $currency OPTIONAL Currency to use for this call
* @return string Formatted currency
*/
public function __invoke($value = null, $currency = null)
Expand Down
2 changes: 1 addition & 1 deletion src/Helper/HeadLink.php
Expand Up @@ -40,7 +40,7 @@ class HeadLink extends Placeholder\Container\Standalone
*
* @var array
*/
protected $_itemKeys = array('charset', 'href', 'hreflang', 'media', 'rel', 'rev', 'type', 'title', 'extras');
protected $_itemKeys = array('charset', 'href', 'hreflang', 'id', 'media', 'rel', 'rev', 'type', 'title', 'extras');

/**
* @var string registry key
Expand Down
1 change: 0 additions & 1 deletion src/Helper/HeadScript.php
Expand Up @@ -369,7 +369,6 @@ public function offsetSet($index, $value)
);
}

$this->_isValid($value);
return $this->getContainer()->offsetSet($index, $value);
}

Expand Down
14 changes: 8 additions & 6 deletions src/Helper/HeadTitle.php
Expand Up @@ -64,16 +64,16 @@ class HeadTitle extends Placeholder\Container\Standalone
*
* @param string $title
* @param string $setType
* @param string $separator
* @return \Zend\View\Helper\HeadTitle
*/
public function __invoke($title = null, $setType = null)
{
if ($setType === null && $this->getDefaultAttachOrder() === null) {
$setType = Placeholder\Container\AbstractContainer::APPEND;
} elseif ($setType === null && $this->getDefaultAttachOrder() !== null) {
$setType = $this->getDefaultAttachOrder();
if (null === $setType) {
$setType = (null === $this->getDefaultAttachOrder())
? Placeholder\Container\AbstractContainer::APPEND
: $this->getDefaultAttachOrder();
}

$title = (string) $title;
if ($title !== '') {
if ($setType == Placeholder\Container\AbstractContainer::SET) {
Expand Down Expand Up @@ -107,6 +107,8 @@ public function setDefaultAttachOrder($setType)
);
}
$this->_defaultAttachOrder = $setType;

return $this;
}

/**
Expand Down Expand Up @@ -140,7 +142,7 @@ public function setTranslator($translate)
return $this;
}

/*
/**
* Retrieve translation object
*
* If none is currently registered, attempts to pull it from the registry
Expand Down
2 changes: 1 addition & 1 deletion src/Helper/Placeholder/Registry.php
Expand Up @@ -80,7 +80,7 @@ public function createContainer($key, array $value = array())
{
$key = (string) $key;

$this->_items[$key] = new $this->_containerClass(array());
$this->_items[$key] = new $this->_containerClass($value);
return $this->_items[$key];
}

Expand Down
10 changes: 7 additions & 3 deletions src/Helper/ServerUrl.php
Expand Up @@ -53,9 +53,13 @@ class ServerUrl extends AbstractHelper
*/
public function __construct()
{
if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] === true)) {
$scheme = 'https';
} else {
switch (true) {
case (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] === true)):
case (isset($_SERVER['HTTP_SCHEME']) && ($_SERVER['HTTP_SCHEME'] == 'https')):
case (isset($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT'] == 443)):
$scheme = 'https';
break;
default:
$scheme = 'http';
}
$this->setScheme($scheme);
Expand Down
9 changes: 9 additions & 0 deletions test/Helper/HeadLinkTest.php
Expand Up @@ -417,5 +417,14 @@ public function testContainerMaintainsCorrectOrderOfItems()

$this->assertEquals($expected, $test);
}

/**
* @issue ZF-10345
*/
public function testIdAttributeIsSupported()
{
$this->helper->appendStylesheet(array('href' => '/bar/baz', 'id' => 'foo'));
$this->assertContains('id="foo"', $this->helper->toString());
}
}

10 changes: 10 additions & 0 deletions test/Helper/HeadTitleTest.php
Expand Up @@ -212,4 +212,14 @@ public function testCanPrependTitlesUsingDefaultAttachOrder()
$placeholder = $this->helper->__invoke('Bar');
$this->assertContains('BarFoo', $placeholder->toString());
}


/**
* @group ZF-10284
*/
public function testReturnTypeDefaultAttachOrder()
{
$this->assertTrue($this->helper->setDefaultAttachOrder('PREPEND') instanceof Helper\HeadTitle);
$this->assertEquals('PREPEND', $this->helper->getDefaultAttachOrder());
}
}
19 changes: 19 additions & 0 deletions test/Helper/Placeholder/RegistryTest.php
Expand Up @@ -180,10 +180,29 @@ public function testGetRegistryRegistersWithGlobalRegistry()
$registered = \Zend\Registry::get(Registry::REGISTRY_KEY);
$this->assertSame($registry, $registered);
}

/**
* @group ZF-10793
*/
public function testSetValueCreateContainer()
{
$this->registry->setContainerClass('ZendTest\View\Helper\Placeholder\MockContainer');
$data = array(
'ZF-10793'
);
$container = $this->registry->createContainer('foo', $data);
$this->assertEquals(array('ZF-10793'), $container->data);
}
}

class MockContainer extends Container\AbstractContainer
{
public $data = array();

public function __construct($data)
{
$this->data = $data;
}
}

class BogusContainer
Expand Down
22 changes: 22 additions & 0 deletions test/Helper/ServerUrlTest.php
Expand Up @@ -151,4 +151,26 @@ public function testServerUrlWithObject()
$url = new Helper\ServerUrl();
$this->assertEquals('http://example.com', $url->__invoke(new \stdClass()));
}

/**
* @group ZF-9919
*/
public function testServerUrlWithScheme()
{
$_SERVER['HTTP_SCHEME'] = 'https';
$_SERVER['HTTP_HOST'] = 'example.com';
$url = new Helper\ServerUrl();
$this->assertEquals('https://example.com', $url->__invoke());
}

/**
* @group ZF-9919
*/
public function testServerUrlWithPort()
{
$_SERVER['SERVER_PORT'] = 443;
$_SERVER['HTTP_HOST'] = 'example.com';
$url = new Helper\ServerUrl();
$this->assertEquals('https://example.com', $url->__invoke());
}
}

0 comments on commit d2649e3

Please sign in to comment.