public function setUp()
 {
     $this->fingerPrinterMock = $this->getMockBuilder('Finga\\FingerPrinter\\FingerPrinterInterface')->getMock();
     //This mock fingerprinter accepts only strings and prefix them with a "xxx:" string.
     $this->fingerPrinterMock->expects($this->any())->method('isFingerprintable')->will($this->returnCallback(function ($value) {
         return is_string($value);
     }));
     $this->fingerPrinterMock->expects($this->any())->method('fingerPrint')->will($this->returnCallback(function ($value) {
         return 'xxx:' . $value;
     }));
     //This mock for the transformationFingerPrinter class transform each value to the string
     //"transform"
     $this->trFingerPrinterMock = $this->getMockBuilder('Finga\\FingerPrinter\\TransformationFingerPrinter')->setConstructorArgs(array($this->fingerPrinterMock))->setMethods(array('getTransformation'))->getMock();
     $this->trFingerPrinterMock->expects($this->any())->method('getTransformation')->will($this->returnValue(function () {
         return 'transformed';
     }));
 }
Exemplo n.º 2
0
 public function testFingerPrintLeafValuesEscapesColumnsAndBackslashes()
 {
     $value = 'asdasd:asdasd\\asasd';
     $escapedFp = addcslashes($this->valueFingerPrinter->fingerPrint($value), '\\:');
     $this->assertEquals(sha1($escapedFp), $this->fingerPrinter->fingerPrint($value));
 }