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

Commit

Permalink
adjust unrefactored tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexispeter committed Jul 2, 2015
1 parent 8c04c8e commit 33b34c9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 36 deletions.
Empty file removed tests/data/img/empty.jpg
Empty file.
Binary file removed tests/data/img/jpg-no-extension
Binary file not shown.
61 changes: 25 additions & 36 deletions tests/library/CM/Image/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

class CM_Image_ImageTest extends CMTest_TestCase {

/**
* @expectedException CM_Exception
* @expectedExceptionMessage Cannot load Imagick instance
*/
public function testConstructCorruptHeader() {
$imageFile = new CM_File(DIR_TEST_DATA . 'img/corrupt-header.jpg');
new CM_Image_Image($imageFile->read());
}

/**
* @expectedException CM_Exception
* @expectedExceptionMessage Cannot load Imagick instance
*/
public function testConstructEmptyData() {
new CM_Image_Image('');
}

/**
* @expectedException CM_Exception
* @expectedExceptionMessage Cannot load Imagick instance
*/
public function testConstructInvalidData() {
new CM_Image_Image('foobar');
}

public function testCrop() {
$imageFile = new CM_File(DIR_TEST_DATA . 'img/test.jpg');
$imageOriginal = new CM_Image_Image($imageFile->read());
Expand Down Expand Up @@ -36,13 +61,6 @@ public function testValidateCorruptContent() {
$this->assertTrue(true);
}

public function testValidateJpgNoExtension() {
$imageFile = new CM_File(DIR_TEST_DATA . 'img/jpg-no-extension');
$image = new CM_Image_Image($imageFile->read());
$image->validate();
$this->assertTrue(true);
}

/**
* @expectedException CM_Exception
* @expectedExceptionMessage Unsupported format
Expand All @@ -53,34 +71,6 @@ public function testValidateUnsupportedFormat() {
$image->validate();
}

/**
* @expectedException CM_Exception
* @expectedExceptionMessage Cannot load Imagick instance
*/
public function testValidateCorruptHeader() {
$imageFile = new CM_File(DIR_TEST_DATA . 'img/corrupt-header.jpg');
$image = new CM_Image_Image($imageFile->read());
}

/**
* @expectedException CM_Exception
* @expectedExceptionMessage Cannot load Imagick instance
*/
public function testValidateEmptyFile() {
$imageFile = new CM_File(DIR_TEST_DATA . 'img/empty.jpg');
$image = new CM_Image_Image($imageFile->read());
$image->validate();
}

/**
* @expectedException CM_Exception
* @expectedExceptionMessage Cannot load Imagick instance
*/
public function testValidateNoImage() {
$imageFile = new CM_File(DIR_TEST_DATA . 'test.jpg.zip');
$image = new CM_Image_Image($imageFile->read());
}

public function testRotate() {
$imageFileOriginal = new CM_File(DIR_TEST_DATA . 'img/test.jpg');
$imageOriginal = new CM_Image_Image($imageFileOriginal->read());
Expand Down Expand Up @@ -130,7 +120,6 @@ public function testGetFormat() {
DIR_TEST_DATA . 'img/test.jpg' => CM_Image_Image::FORMAT_JPEG,
DIR_TEST_DATA . 'img/test.gif' => CM_Image_Image::FORMAT_GIF,
DIR_TEST_DATA . 'img/test.png' => CM_Image_Image::FORMAT_PNG,
DIR_TEST_DATA . 'img/jpg-no-extension' => CM_Image_Image::FORMAT_JPEG,
DIR_TEST_DATA . 'img/corrupt-content.jpg' => CM_Image_Image::FORMAT_JPEG,
);

Expand Down

0 comments on commit 33b34c9

Please sign in to comment.