Completed
Push — 1 ( 09a010...9d556f )
by Robbie
05:58 queued 02:30
created

PasswordEncryptor_PBKDF2Test::testEncrypt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
class PasswordEncryptor_PBKDF2Test extends SapphireTest
4
{
5
	public function testGetIterations()
6
	{
7
		$encryptor = new PasswordEncryptor_PBKDF2('sha512', 12345);
8
		$this->assertSame(12345, $encryptor->getIterations());
0 ignored issues
show
Bug introduced by
The method assertSame() does not exist on PasswordEncryptor_PBKDF2Test. Did you maybe mean assertEmailSent()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

8
		$this->/** @scrutinizer ignore-call */ 
9
         assertSame(12345, $encryptor->getIterations());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
9
	}
10
11
	public function testEncrypt()
12
	{
13
		$encryptor = new PasswordEncryptor_PBKDF2('sha512', 10000);
14
		$salt = 'predictablesaltforunittesting';
15
		$result = $encryptor->encrypt('opensesame', $salt);
16
		$this->assertSame(
17
			'6bafcacb90',
18
			substr($result, 0, 10),
19
			'Hashed password with predictable salt did not match fixtured expectation'
20
		);
21
	}
22
23
	/**
24
	 * @expectedException Exception
25
	 * @expectedExceptionMessage Hash algorithm "foobar" not found
26
	 */
27
	public function testThrowsExceptionWhenInvalidAlgorithmIsProvided()
28
	{
29
		new PasswordEncryptor_PBKDF2('foobar');
30
	}
31
}
32