3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
22 * BasicBlobCrypter test case.
24 class BasicBlobCrypterTest
extends PHPUnit_Framework_TestCase
{
27 * @var BasicBlobCrypter
29 private $BasicBlobCrypter;
32 * Prepares the environment before running a test.
34 protected function setUp() {
36 $this->BasicBlobCrypter
= new BasicBlobCrypter();
40 * Cleans up the environment after running a test.
42 protected function tearDown() {
43 $this->BasicBlobCrypter
= null;
48 * Tests BasicBlobCrypter->__construct()
50 public function test__construct() {
51 $this->BasicBlobCrypter
->__construct();
55 * Tests BasicBlobCrypter->wrap()
57 public function testWrap() {
65 $wrapped = $this->BasicBlobCrypter
->wrap($test);
66 $unwrapped = $this->BasicBlobCrypter
->unwrap($wrapped, 3600);
67 $this->assertEquals($unwrapped['o'], 'o');
68 $this->assertEquals($unwrapped['v'], 'v');
69 $this->assertEquals($unwrapped['a'], 'a');
70 $this->assertEquals($unwrapped['d'], 'd');
71 $this->assertEquals($unwrapped['u'], 'u');
72 $this->assertEquals($unwrapped['m'], 'm');
76 * Tests BasicBlobCrypter->wrap() exception
78 public function testWrapException() {
79 $this->setExpectedException('BlobExpiredException');
87 $wrapped = $this->BasicBlobCrypter
->wrap($test);
88 /* there is a 180 seconds clock skew allowed, so this way we make sure it's expired */
89 $this->BasicBlobCrypter
->unwrap($wrapped, - 4000);