PHP Classes

File: test/Picamator/SteganographyKit/Iterator/ImageRandomIteratorTest.php

Recommend this page to a friend!
  Classes of Sergii Pryz   PHP Steganography Kit   test/Picamator/SteganographyKit/Iterator/ImageRandomIteratorTest.php   Download  
File: test/Picamator/SteganographyKit/Iterator/ImageRandomIteratorTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: PHP Steganography Kit
Library of algorithms to encode messages in images
Author: By
Last change:
Date: 9 years ago
Size: 1,801 bytes
 

Contents

Class file image Download
<?php
/**
 * ImageIterator SteganographyKit UnitTest
 *
 * @link https://github.com/picamator/SteganographyKit
 * @license http://opensource.org/licenses/BSD-3-Clause New BSD License
 */

use Picamator\SteganographyKit\Iterator\ImageRandomIterator;

class
ImageRandomIteratorTest extends BaseTest
{
   
/**
     * @dataProvider providerIterator
     * @param string $path
     * @param array $imgSize
     * @param integer $expectedSize
     */
   
public function testIterator($path, array $imgSize, $expectedSize)
    {
       
$path = $this->getDataPath($path);
       
       
// mock image
       
$image = $this->getMock(
           
'Picamator\SteganographyKit\Image\Image',
            array(
'getSize', 'getImage'),
            array(array(
'path' => $path))
        );
       
$image->expects($this->once())
            ->
method('getSize')->will($this->returnValue($imgSize));
       
       
$imageSrc = imagecreatefrompng($path);
       
$image->expects($this->once())
            ->
method('getImage')->will($this->returnValue($imageSrc));

       
// cretate iterator
       
$iterator = new ImageRandomIterator($image, 123456);
       
$actual = iterator_to_array($iterator);
               
       
$this->assertEquals($expectedSize, count($actual));
    }
   
    public function
providerIterator()
    {
        return array(
            array(
'original_50_50.png', array('width' => 1, 'height' => 3), 3),
            array(
'original_50_50.png', array('width' => 3, 'height' => 1), 3),
            array(
'original_50_50.png', array('width' => 1, 'height' => 1), 1),
            array(
'original_50_50.png', array('width' => 1, 'height' => 2), 2),
            array(
'original_50_50.png', array('width' => 50, 'height' => 50), 2500)
        );
    }
}