/** * @covers Veles\Model\User::getSalt */ public function testGetSalt() { $expected = null; $actual = $this->object->getSalt(); $msg = 'User::getSalt() returns wrong result!'; $this->assertSame($expected, $actual, $msg); $expected = '$2a$07$usesomesillystringfor'; $db_result = ['id' => 1, 'email' => '*****@*****.**', 'hash' => '$2a$07$usesomesillystringforeGlOaUExBSD9HxuEYk2ZFaeDhggU716O', 'group' => UsrGroup::GUEST, 'last_login' => 'string']; $adapter = $this->getMockBuilder('\\Veles\\DataBase\\Adapters\\PdoAdapter')->setMethods(['row'])->getMock(); $adapter->expects($this->once())->method('row')->willReturn($db_result); Db::setAdapter($adapter); $this->object->getById(1); $actual = $this->object->getSalt(); $this->assertSame($expected, $actual, $msg); }