Delete MemoryImageTest.php and TableFullTest.php

This commit is contained in:
Ivan Lanin 2014-03-25 10:07:25 +07:00
parent 92a76d0c0c
commit 841157e442
2 changed files with 0 additions and 208 deletions

View File

@ -1,78 +0,0 @@
<?php
namespace PhpOffice\PhpWord\Tests\Section;
use PhpOffice\PhpWord\Section\MemoryImage;
class MemoryImageTest extends \PHPUnit_Framework_TestCase
{
public function testPNG()
{
$src = __DIR__ . "/../_files/images/firefox.png";
$oMemoryImage = new MemoryImage($src);
$this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $oMemoryImage);
$this->assertEquals($oMemoryImage->getSource(), $src);
$this->assertEquals($oMemoryImage->getMediaId(), md5($src));
$this->assertEquals($oMemoryImage->getImageCreateFunction(), 'imagecreatefrompng');
$this->assertEquals($oMemoryImage->getImageFunction(), 'imagepng');
$this->assertEquals($oMemoryImage->getImageExtension(), 'png');
$this->assertEquals($oMemoryImage->getImageType(), 'image/png');
}
public function testGIF()
{
$src = __DIR__ . "/../_files/images/mario.gif";
$oMemoryImage = new MemoryImage($src);
$this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $oMemoryImage);
$this->assertEquals($oMemoryImage->getSource(), $src);
$this->assertEquals($oMemoryImage->getMediaId(), md5($src));
$this->assertEquals($oMemoryImage->getImageCreateFunction(), 'imagecreatefromgif');
$this->assertEquals($oMemoryImage->getImageFunction(), 'imagegif');
$this->assertEquals($oMemoryImage->getImageExtension(), 'gif');
$this->assertEquals($oMemoryImage->getImageType(), 'image/gif');
}
public function testJPG()
{
$src = __DIR__ . "/../_files/images/earth.jpg";
$oMemoryImage = new MemoryImage($src);
$this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $oMemoryImage);
$this->assertEquals($oMemoryImage->getSource(), $src);
$this->assertEquals($oMemoryImage->getMediaId(), md5($src));
$this->assertEquals($oMemoryImage->getImageCreateFunction(), 'imagecreatefromjpeg');
$this->assertEquals($oMemoryImage->getImageFunction(), 'imagejpeg');
$this->assertEquals($oMemoryImage->getImageExtension(), 'jpg');
$this->assertEquals($oMemoryImage->getImageType(), 'image/jpeg');
}
public function testBMP()
{
$oMemoryImage = new MemoryImage(__DIR__ . "/../_files/images/duke_nukem.bmp");
$this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $oMemoryImage);
$this->assertEquals($oMemoryImage->getImageCreateFunction(), null);
$this->assertEquals($oMemoryImage->getImageFunction(), null);
$this->assertEquals($oMemoryImage->getImageExtension(), null);
$this->assertEquals($oMemoryImage->getImageType(), 'image/x-ms-bmp');
}
public function testStyle()
{
$oMemoryImage = new MemoryImage(
__DIR__ . "/../_files/images/earth.jpg",
array('width' => 210, 'height' => 210, 'align' => 'center')
);
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oMemoryImage->getStyle());
}
public function testRelationID()
{
$oMemoryImage = new MemoryImage(__DIR__ . "/../_files/images/earth.jpg");
$iVal = rand(1, 1000);
$oMemoryImage->setRelationId($iVal);
$this->assertEquals($oMemoryImage->getRelationId(), $iVal);
}
}

View File

@ -1,130 +0,0 @@
<?php
namespace PhpOffice\PhpWord\Tests\Style;
use PhpOffice\PhpWord\Style\TableFull;
/**
* @runTestsInSeparateProcesses
*/
class TableFullTest extends \PHPUnit_Framework_TestCase
{
/**
* Test class construction
*
* There are 3 variables for class constructor:
* - $styleTable: Define table styles
* - $styleFirstRow: Define style for the first row
* - $styleLastRow: Define style for the last row (reserved)
*/
public function testConstruct()
{
$styleTable = array('bgColor' => 'FF0000');
$styleFirstRow = array('borderBottomSize' => 3);
$object = new TableFull($styleTable, $styleFirstRow);
$this->assertEquals('FF0000', $object->getBgColor());
$firstRow = $object->getFirstRow();
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\TableFull', $firstRow);
$this->assertEquals(3, $firstRow->getBorderBottomSize());
}
/**
* Test setting style with normal value
*/
public function testSetGetNormal()
{
$object = new TableFull();
$attributes = array(
'bgColor' => 'FF0000',
'borderTopSize' => 4,
'borderTopColor' => 'FF0000',
'borderLeftSize' => 4,
'borderLeftColor' => 'FF0000',
'borderRightSize' => 4,
'borderRightColor' => 'FF0000',
'borderBottomSize' => 4,
'borderBottomColor' => 'FF0000',
'borderInsideHSize' => 4,
'borderInsideHColor' => 'FF0000',
'borderInsideVSize' => 4,
'borderInsideVColor' => 'FF0000',
'cellMarginTop' => 240,
'cellMarginLeft' => 240,
'cellMarginRight' => 240,
'cellMarginBottom' => 240,
);
foreach ($attributes as $key => $value) {
$set = "set{$key}";
$get = "get{$key}";
$object->$set($value);
$this->assertEquals($value, $object->$get());
}
}
/**
* Test border color
*
* Set border color and test if each part has the same color
* While looping, push values array to be asserted with getBorderColor
*/
public function testBorderColor()
{
$object = new TableFull();
$parts = array('Top', 'Left', 'Right', 'Bottom', 'InsideH', 'InsideV');
$value = 'FF0000';
$object->setBorderColor($value);
foreach ($parts as $part) {
$get = "getBorder{$part}Color";
$values[] = $value;
$this->assertEquals($value, $object->$get());
}
$this->assertEquals($values, $object->getBorderColor());
}
/**
* Test border size
*
* Set border size and test if each part has the same size
* While looping, push values array to be asserted with getBorderSize
* Value is in eights of a point, i.e. 4 / 8 = .5pt
*/
public function testBorderSize()
{
$object = new TableFull();
$parts = array('Top', 'Left', 'Right', 'Bottom', 'InsideH', 'InsideV');
$value = 4;
$object->setBorderSize($value);
foreach ($parts as $part) {
$get = "getBorder{$part}Size";
$values[] = $value;
$this->assertEquals($value, $object->$get());
}
$this->assertEquals($values, $object->getBorderSize());
}
/**
* Test cell margin
*
* Set cell margin and test if each part has the same margin
* While looping, push values array to be asserted with getCellMargin
* Value is in twips
*/
public function testCellMargin()
{
$object = new TableFull();
$parts = array('Top', 'Left', 'Right', 'Bottom');
$value = 240;
$object->setCellMargin($value);
foreach ($parts as $part) {
$get = "getCellMargin{$part}";
$values[] = $value;
$this->assertEquals($value, $object->$get());
}
$this->assertEquals($values, $object->getCellMargin());
}
}