|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * This file is part of PHPWord - A pure PHP library for reading and writing |
| 4 | + * word processing documents. |
| 5 | + * |
| 6 | + * PHPWord is free software distributed under the terms of the GNU Lesser |
| 7 | + * General Public License version 3 as published by the Free Software Foundation. |
| 8 | + * |
| 9 | + * For the full copyright and license information, please read the LICENSE |
| 10 | + * file that was distributed with this source code. For the full list of |
| 11 | + * contributors, visit https://github.com/PHPOffice/PHPWord/contributors. |
| 12 | + * |
| 13 | + * @link https://github.com/PHPOffice/PHPWord |
| 14 | + * @copyright 2010-2014 PHPWord contributors |
| 15 | + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
| 16 | + */ |
| 17 | + |
| 18 | +namespace PhpOffice\PhpWord\Tests\Element; |
| 19 | + |
| 20 | +use PhpOffice\PhpWord\Element\SDT; |
| 21 | + |
| 22 | +/** |
| 23 | + * Test class for PhpOffice\PhpWord\Element\SDT |
| 24 | + * |
| 25 | + * @coversDefaultClass \PhpOffice\PhpWord\Element\SDT |
| 26 | + */ |
| 27 | +class SDTTest extends \PHPUnit_Framework_TestCase |
| 28 | +{ |
| 29 | + /** |
| 30 | + * Create new instance |
| 31 | + */ |
| 32 | + public function testConstruct() |
| 33 | + { |
| 34 | + $types = array('comboBox', 'dropDownList', 'date'); |
| 35 | + $type = $types[rand(0, 2)]; |
| 36 | + $value = rand(0, 100); |
| 37 | + $object = new SDT($type); |
| 38 | + $object->setValue($value);; |
| 39 | + $object->setListItems($types);; |
| 40 | + |
| 41 | + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\SDT', $object); |
| 42 | + $this->assertEquals($type, $object->getType()); |
| 43 | + $this->assertEquals($types, $object->getListItems()); |
| 44 | + $this->assertEquals($value, $object->getValue()); |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * Test set type exception |
| 49 | + * |
| 50 | + * @expectedException \InvalidArgumentException |
| 51 | + * @expectedExceptionMessage Invalid style value |
| 52 | + */ |
| 53 | + public function testSetTypeException() |
| 54 | + { |
| 55 | + $object = new SDT('comboBox'); |
| 56 | + $object->setType('foo'); |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Test set type |
| 61 | + */ |
| 62 | + public function testSetTypeNull() |
| 63 | + { |
| 64 | + $object = new SDT('comboBox'); |
| 65 | + $object->setType(' '); |
| 66 | + |
| 67 | + $this->assertEquals('comboBox', $object->getType()); |
| 68 | + } |
| 69 | +} |
0 commit comments