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

Recommend this page to a friend!
  Classes of Sergii Pryz  >  PHP Steganography Kit  >  test/Picamator/SteganographyKit/Iterator/SecretTextIteratorTest.php  >  Download  
File: test/Picamator/SteganographyKit/Iterator/SecretTextIteratorTest.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: 5 years ago
Size: 2,004 bytes
 

Contents

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

use Picamator\SteganographyKit\Iterator\SecretTextIterator;

class
SecretTextIteratorTest extends BaseTest
{
   
/**
     * @dataProvider providerIterator
     * @param string $binaryData
     * @param integer $itemSize
     * @param array $expected
     */
   
public function testIterator($binaryData, $itemSize, array $expected)
    {
       
// mock image
       
$secretText = $this->getMock(
           
'Picamator\SteganographyKit\SecretText\PlainText',
            array(
'getBinaryData', 'getBinaryItemSize')
        );
       
$secretText->expects($this->once())
            ->
method('getBinaryData')->will($this->returnValue($binaryData));
       
       
$secretText->expects($this->once())
            ->
method('getBinaryItemSize')->will($this->returnValue($itemSize));

       
// cretate iterator
       
$iterator = new SecretTextIterator($secretText);
       
$actual = iterator_to_array($iterator);
       
       
$this->assertEquals($expected, array_values($actual));
    }
   
    public function
providerIterator()
    {
        return array(
            array(
               
'10011101101010111111111000000000',
                
3,
                array(
                   
'100',
                   
'111',
                   
'011',
                   
'010',
                   
'101',
                   
'111',
                   
'111',
                   
'110',
                   
'000',
                   
'000',
                   
'00',
                )
            ),
            array(
               
'10011',
                
1,
                array(
                   
'1',
                   
'0',
                   
'0',
                   
'1',
                   
'1'
               
)
            ),
        );
    }
}


For more information send a message to info at phpclasses dot org.