PHP Classes
elePHPant
Icontem

File: tests/CompoundIndexTest.php

Recommend this page to a friend!
  Classes of Scott Arciszewski  >  Cipher Sweet  >  tests/CompoundIndexTest.php  >  Download  
File: tests/CompoundIndexTest.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Cipher Sweet
Encrypt data in away that can be searched
Author: By
Last change:
Date: 6 months ago
Size: 1,077 bytes
 

Contents

Class file image Download
<?php
namespace ParagonIE\CipherSweet\Tests;

use
ParagonIE\CipherSweet\CompoundIndex;
use
ParagonIE\CipherSweet\Transformation\LastFourDigits;
use
PHPUnit\Framework\TestCase;

/**
 * Class CompoundIndexTest
 * @package ParagonIE\CipherSweet\Tests
 */
class CompoundIndexTest extends TestCase
{
   
/**
     * @throws \Exception
     */
   
public function testCompoundIndex()
    {
       
$cIdx = new CompoundIndex(
           
'ssn_hivstatus',
            [
'ssn', 'hivstatus'],
           
32,
           
true
       
);
       
$cIdx->addTransform('ssn', new LastFourDigits());
       
$packed = $cIdx->getPacked([
           
'ssn' => '123-45-6789',
           
'hivstatus' => true
       
]);
       
$this->assertSame(
           
'{"ssn":"0400000000000000Njc4OQ==","hivstatus":true}',
           
$packed
       
);
       
$packed = $cIdx->getPacked([
           
'ssn' => '123-45-6789',
           
'hivstatus' => false
       
]);
       
$this->assertSame(
           
'{"ssn":"0400000000000000Njc4OQ==","hivstatus":false}',
           
$packed
       
);
    }
}