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

Commit

Permalink
Merge branch 'hotfix/7' into develop
Browse files Browse the repository at this point in the history
Forward port #7
  • Loading branch information
mwillbanks committed Jul 17, 2015
2 parents 323fbb8 + b7b1a32 commit e888701
Show file tree
Hide file tree
Showing 2 changed files with 257 additions and 0 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Changelog

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 2.5.2 - TBD

### Added

- Nothing.

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- Nothing.
236 changes: 236 additions & 0 deletions test/LabelAwareTraitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace ZendTest\Form;

use PHPUnit_Framework_TestCase as TestCase;

/**
* @requires PHP 5.4
* @group Zend_Form
*/
class LabelAwareTraitTest extends TestCase
{

public function testSetLabelAttributes()
{
$object = $this->getObjectForTrait('\Zend\Form\LabelAwareTrait');

$this->assertAttributeEquals(null, 'labelAttributes', $object);

$labelAttributes = [
'test',
'test2',
];

$object->setLabelAttributes($labelAttributes);

$this->assertAttributeEquals($labelAttributes, 'labelAttributes', $object);
}

public function testGetEmptyLabelAttributes()
{
$object = $this->getObjectForTrait('\Zend\Form\LabelAwareTrait');

$labelAttributes = $object->getLabelAttributes();

$this->assertEquals(null, $labelAttributes);
}

public function testGetLabelAttributes()
{
$object = $this->getObjectForTrait('\Zend\Form\LabelAwareTrait');

$labelAttributes = [
'test',
'test2',
];

$object->setLabelAttributes($labelAttributes);

$getLabelAttributes = $object->getLabelAttributes();

$this->assertEquals($labelAttributes, $getLabelAttributes);
}

public function testSetEmptyLabelOptions()
{
$object = $this->getObjectForTrait('\Zend\Form\LabelAwareTrait');

$labelOptions = [];

$object->setLabelOptions($labelOptions);

$this->assertEquals($labelOptions, []);
}

public function testSetLabelOptions()
{
$object = $this->getObjectForTrait('\Zend\Form\LabelAwareTrait');

$labelOptions = [
'foo' => 'bar',
'foo2' => 'bar2',
];


$object->setLabelOptions($labelOptions);

$retrievedLabelOptions = $object->getLabelOptions();

$this->assertEquals($retrievedLabelOptions, $labelOptions);
}

public function testGetEmptyLabelOptions()
{
$object = $this->getObjectForTrait('\Zend\Form\LabelAwareTrait');

$labelOptions = $object->getLabelOptions();

$this->assertEquals($labelOptions, []);
}

public function testGetLabelOptions()
{
$object = $this->getObjectForTrait('\Zend\Form\LabelAwareTrait');

$labelOptions = [
'foo' => 'bar',
'foo2' => 'bar',
];

$object->setLabelOptions($labelOptions);

$retrievedLabelOptions = $object->getLabelOptions();

$this->assertEquals($labelOptions, $retrievedLabelOptions);
}

public function testClearLabelOptions()
{
$object = $this->getObjectForTrait('\Zend\Form\LabelAwareTrait');

$labelOptions = [
'foo' => 'bar',
'foo2' => 'bar',
];

$object->setLabelOptions($labelOptions);

$object->clearLabelOptions();

$retrievedLabelOptions = $object->getLabelOptions();

$this->assertEquals([], $retrievedLabelOptions);
}

public function testRemoveLabelOptions()
{
$object = $this->getObjectForTrait('\Zend\Form\LabelAwareTrait');

$labelOptions = [
'foo' => 'bar',
'foo2' => 'bar2',
];

$object->setLabelOptions($labelOptions);

$toRemoveLabelOptions = [
'foo',
];

$object->removeLabelOptions($toRemoveLabelOptions);

$expectedLabelOptions = [
'foo2' => 'bar2',
];

$retrievedLabelOptions = $object->getLabelOptions();

$this->assertEquals($expectedLabelOptions, $retrievedLabelOptions);
}

public function testSetLabelOption()
{
$object = $this->getObjectForTrait('\Zend\Form\LabelAwareTrait');

$object->setLabelOption('foo', 'bar');

$expectedLabelOptions = [
'foo' => 'bar',
];

$retrievedLabelOptions = $object->getLabelOptions();

$this->assertEquals($expectedLabelOptions, $retrievedLabelOptions);
}

public function testGetInvalidLabelOption()
{
$object = $this->getObjectForTrait('\Zend\Form\LabelAwareTrait');

$invalidOption = 'foo';

$retrievedOption = $object->getLabelOption($invalidOption);

$this->assertEquals(null, $retrievedOption);
}

public function testGetLabelOption()
{
$object = $this->getObjectForTrait('\Zend\Form\LabelAwareTrait');

$option = 'foo';
$value = 'bar';

$object->setLabelOption($option, $value);

$retrievedValue = $object->getLabelOption($option);

$this->assertEquals($retrievedValue, $value);
}

public function testRemoveLabelOption()
{
$object = $this->getObjectForTrait('\Zend\Form\LabelAwareTrait');

$option = 'foo';
$value = 'bar';

$object->setLabelOption($option, $value);

$object->removeLabelOption($option);

$retrievedValue = $object->getLabelOption($option);

$this->assertEquals(null, $retrievedValue);
}

public function testHasValidLabelOption()
{
$object = $this->getObjectForTrait('\Zend\Form\LabelAwareTrait');

$option = 'foo';
$value = 'bar';

$object->setLabelOption($option, $value);

$hasLabelOptionResult = $object->hasLabelOption($option);
$this->assertTrue($hasLabelOptionResult);
}

public function testHasInvalidLabelOption()
{
$object = $this->getObjectForTrait('\Zend\Form\LabelAwareTrait');

$option = 'foo';

$hasLabelOptionResult = $object->hasLabelOption($option);
$this->assertFalse($hasLabelOptionResult);
}
}

0 comments on commit e888701

Please sign in to comment.