153 lines
4.4 KiB
PHP
Raw Normal View History

2014-05-29 16:44:00 +02:00
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
2022-09-16 11:45:45 +02:00
*
2014-05-29 16:44:00 +02:00
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
2022-09-16 14:09:17 +02:00
namespace PhpOffice\PhpWordTests\Style;
use PhpOffice\PhpWord\Style\Line;
2014-05-29 16:44:00 +02:00
/**
2022-09-16 11:45:45 +02:00
* Test class for PhpOffice\PhpWord\Style\Image.
2014-05-29 16:44:00 +02:00
*
* @coversDefaultClass \PhpOffice\PhpWord\Style\Image
2022-09-16 11:45:45 +02:00
*
2014-05-29 16:44:00 +02:00
* @runTestsInSeparateProcesses
*/
class LineTest extends \PHPUnit\Framework\TestCase
2014-05-29 16:44:00 +02:00
{
/**
2022-09-16 11:45:45 +02:00
* Test setting style with normal value.
2014-05-29 16:44:00 +02:00
*/
2022-09-16 11:45:45 +02:00
public function testSetGetNormal(): void
2014-05-29 16:44:00 +02:00
{
$object = new Line();
2022-09-16 11:45:45 +02:00
$properties = [
2014-05-29 16:44:00 +02:00
'connectorType' => \PhpOffice\PhpWord\Style\Line::CONNECTOR_TYPE_STRAIGHT,
2022-09-16 11:45:45 +02:00
'beginArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_BLOCK,
'endArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_OVAL,
'dash' => \PhpOffice\PhpWord\Style\Line::DASH_STYLE_LONG_DASH_DOT_DOT,
'weight' => 10,
'color' => 'red',
];
2014-05-29 16:44:00 +02:00
foreach ($properties as $key => $value) {
$set = "set{$key}";
$get = "get{$key}";
$object->$set($value);
2022-09-16 11:45:45 +02:00
self::assertEquals($value, $object->$get());
2014-05-29 16:44:00 +02:00
}
}
/**
2022-09-16 11:45:45 +02:00
* Test setStyleValue method.
2014-05-29 16:44:00 +02:00
*/
2022-09-16 11:45:45 +02:00
public function testSetStyleValue(): void
2014-05-29 16:44:00 +02:00
{
$object = new Line();
2022-09-16 11:45:45 +02:00
$properties = [
2014-05-29 16:44:00 +02:00
'connectorType' => \PhpOffice\PhpWord\Style\Line::CONNECTOR_TYPE_STRAIGHT,
2022-09-16 11:45:45 +02:00
'beginArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_BLOCK,
'endArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_OVAL,
'dash' => \PhpOffice\PhpWord\Style\Line::DASH_STYLE_LONG_DASH_DOT_DOT,
'weight' => 10,
'color' => 'red',
];
2014-05-29 16:44:00 +02:00
foreach ($properties as $key => $value) {
$get = "get{$key}";
$object->setStyleValue("{$key}", $value);
2022-09-16 11:45:45 +02:00
self::assertEquals($value, $object->$get());
2014-05-29 16:44:00 +02:00
}
}
2014-05-29 16:44:00 +02:00
/**
2022-09-16 11:45:45 +02:00
* Test set/get flip.
2014-05-29 16:44:00 +02:00
*/
2022-09-16 11:45:45 +02:00
public function testSetGetFlip(): void
2014-05-29 16:44:00 +02:00
{
$expected = true;
2014-05-29 16:44:00 +02:00
$object = new Line();
$object->setFlip($expected);
2022-09-16 11:45:45 +02:00
self::assertEquals($expected, $object->isFlip());
2014-05-29 16:44:00 +02:00
}
/**
2022-09-16 11:45:45 +02:00
* Test set/get connectorType.
2014-05-29 16:44:00 +02:00
*/
2022-09-16 11:45:45 +02:00
public function testSetGetConnectorType(): void
2014-05-29 16:44:00 +02:00
{
$expected = \PhpOffice\PhpWord\Style\Line::CONNECTOR_TYPE_STRAIGHT;
2014-05-29 16:44:00 +02:00
$object = new Line();
$object->setConnectorType($expected);
2022-09-16 11:45:45 +02:00
self::assertEquals($expected, $object->getConnectorType());
2014-05-29 16:44:00 +02:00
}
2014-05-29 16:44:00 +02:00
/**
2022-09-16 11:45:45 +02:00
* Test set/get weight.
2014-05-29 16:44:00 +02:00
*/
2022-09-16 11:45:45 +02:00
public function testSetGetWeight(): void
2014-05-29 16:44:00 +02:00
{
$expected = 10;
2014-05-29 16:44:00 +02:00
$object = new Line();
$object->setWeight($expected);
2022-09-16 11:45:45 +02:00
self::assertEquals($expected, $object->getWeight());
2014-05-29 16:44:00 +02:00
}
/**
2022-09-16 11:45:45 +02:00
* Test set/get color.
2014-05-29 16:44:00 +02:00
*/
2022-09-16 11:45:45 +02:00
public function testSetGetColor(): void
2014-05-29 16:44:00 +02:00
{
$expected = 'red';
2014-05-29 16:44:00 +02:00
$object = new Line();
$object->setColor($expected);
2022-09-16 11:45:45 +02:00
self::assertEquals($expected, $object->getColor());
2014-05-29 16:44:00 +02:00
}
/**
2022-09-16 11:45:45 +02:00
* Test set/get dash.
2014-05-29 16:44:00 +02:00
*/
2022-09-16 11:45:45 +02:00
public function testSetGetDash(): void
2014-05-29 16:44:00 +02:00
{
$expected = \PhpOffice\PhpWord\Style\Line::DASH_STYLE_LONG_DASH_DOT_DOT;
2014-05-29 16:44:00 +02:00
$object = new Line();
$object->setDash($expected);
2022-09-16 11:45:45 +02:00
self::assertEquals($expected, $object->getDash());
2014-05-29 16:44:00 +02:00
}
/**
2022-09-16 11:45:45 +02:00
* Test set/get beginArrow.
2014-05-29 16:44:00 +02:00
*/
2022-09-16 11:45:45 +02:00
public function testSetGetBeginArrow(): void
2014-05-29 16:44:00 +02:00
{
$expected = \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_BLOCK;
2014-05-29 16:44:00 +02:00
$object = new Line();
$object->setBeginArrow($expected);
2022-09-16 11:45:45 +02:00
self::assertEquals($expected, $object->getBeginArrow());
2014-05-29 16:44:00 +02:00
}
/**
2022-09-16 11:45:45 +02:00
* Test set/get endArrow.
2014-05-29 16:44:00 +02:00
*/
2022-09-16 11:45:45 +02:00
public function testSetGetEndArrow(): void
2014-05-29 16:44:00 +02:00
{
$expected = \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_CLASSIC;
2014-05-29 16:44:00 +02:00
$object = new Line();
$object->setEndArrow($expected);
2022-09-16 11:45:45 +02:00
self::assertEquals($expected, $object->getEndArrow());
2014-05-29 16:44:00 +02:00
}
}