Esempio n. 1
0
 public function testRetrieve()
 {
     $userId = 'abc';
     $identifier = 'foo';
     $this->crypto->expects($this->once())->method('decrypt')->with('baz')->willReturn(json_encode('bar'));
     $qb = $this->getMockBuilder('\\OC\\DB\\QueryBuilder\\QueryBuilder')->setConstructorArgs([$this->dbConnection])->setMethods(['execute'])->getMock();
     $qb->expects($this->once())->method('execute')->willReturn($this->getQeuryResult(['credentials' => 'baz']));
     $this->dbConnection->expects($this->once())->method('getQueryBuilder')->willReturn($qb);
     $this->manager->retrieve($userId, $identifier);
 }
Esempio n. 2
0
 protected function setUp()
 {
     parent::setUp();
     $this->wrappedSession = $this->getMockBuilder('OCP\\ISession')->disableOriginalConstructor()->getMock();
     $this->crypto = $this->getMockBuilder('OCP\\Security\\ICrypto')->disableOriginalConstructor()->getMock();
     $this->crypto->expects($this->any())->method('encrypt')->willReturnCallback(function ($input) {
         return $input;
     });
     $this->crypto->expects($this->any())->method('decrypt')->willReturnCallback(function ($input) {
         return substr($input, 1, -1);
     });
     $this->instance = new CryptoSessionData($this->wrappedSession, $this->crypto, 'PASS');
 }