File: test/Picamator/SteganographyKit/StegoKey/RandomKeyTest.php

Recommend this page to a friend!
  Classes of Sergii Pryz  >  PHP Steganography Kit  >  test/Picamator/SteganographyKit/StegoKey/RandomKeyTest.php  >  Download  
File: test/Picamator/SteganographyKit/StegoKey/RandomKeyTest.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,156 bytes
 

Contents

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

use Picamator\SteganographyKit\StegoKey\RandomKey;

class
RandomKeyTest extends BaseTest
{
   
/**
     * Stegonagraphy key
     *
     * @var StegoKey
     */
   
protected $stegoKey;
   
    public function
setUp()
    {
       
parent::setUp();
       
$this->stegoKey = new RandomKey();
    }
   
   
/**
     * @dataProvider providerFailedSecretKey
     * @expectedException Picamator\SteganographyKit\InvalidArgumentException
     * @param string $secretKey
     */
   
public function testFailedSecretKey($secretKey)
    {
       
$this->stegoKey->setSecretKey($secretKey);
    }
   
   
/**
     * @dataProvider providerSuccessSecretKey
     * @param integer $secretKey
     */
   
public function testSuccessSecretKey($secretKey)
    {
       
$result = $this->stegoKey->setSecretKey($secretKey);
       
       
$this->assertTrue(is_object($result));
    }
   
    public function
testGenerateSecretKey()
    {
       
$secretKey = $this->stegoKey->generateSecretKey();
       
       
$this->assertGreaterThanOrEqual(RandomKey::MIN_SECRET_KEY_LENGTH, strlen($secretKey));
       
$this->assertLessThanOrEqual(RandomKey::MAX_SECRET_KEY_LENGTH, strlen($secretKey));
    }
   
    public function
testGenerateSecretKeyAutoSet()
    {
       
$expected = $this->stegoKey->generateSecretKey(true);
       
$actual = $this->stegoKey->getSecretKey();
       
       
$this->assertEquals($expected, $actual);
    }
       
    public function
providerFailedSecretKey()
    {
        return array(
            array(
str_repeat('t', RandomKey::MIN_SECRET_KEY_LENGTH - 1)),
            array((int)
str_repeat('9', RandomKey::MAX_SECRET_KEY_LENGTH + 1)),
            array(
'test')
        );
    }
   
    public function
providerSuccessSecretKey()
    {
        return array(
            array((int)
str_repeat('1', RandomKey::MIN_SECRET_KEY_LENGTH)),
            array((int)
str_repeat('1', RandomKey::MAX_SECRET_KEY_LENGTH)),
        );
    }
}



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