コード例 #1
0
ファイル: ExtractorTest.php プロジェクト: vipkailiai/FCVOVA
 public function testSetService()
 {
     /**
      * @var \OAuth\Common\Service\ServiceInterface $service
      */
     $service = $this->getMock('\\OAuth\\Common\\Service\\ServiceInterface');
     $extractor = new Extractor();
     $extractor->setService($service);
 }
コード例 #2
0
ファイル: ExtractorTest.php プロジェクト: kunal981/php-oauth
 public function testSaveImage()
 {
     $imagePathToSave = __DIR__ . '/' . uniqid() . '.png';
     $imageUrl = 'http://upload.wikimedia.org/wikipedia/commons/3/31/Red-dot-5px.png';
     // $imageRawBase64 = base64_encode(file_get_contents($imageUrl));
     $imageRawBase64 = 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
     if (!is_writable(dirname($imagePathToSave))) {
         $this->markTestSkipped('Directory not writable');
     }
     /**
      * @var \OAuth\Common\Service\ServiceInterface|\PHPUnit_Framework_MockObject_MockObject $service
      */
     $service = $this->getMock('\\OAuth\\Common\\Service\\AbstractService', ['httpRequest', 'request', 'getAuthorizationUri'], [], '', false);
     $service->expects($this->any())->method('httpRequest')->willReturn(base64_decode($imageRawBase64));
     $extractor = new Extractor(FieldsValues::construct([Extractor::FIELD_IMAGE_URL => $imageUrl]));
     $extractor->setService($service);
     $this->assertFalse(is_file($imagePathToSave));
     $extractor->saveImage($imagePathToSave, 10, 10);
     $this->assertTrue(is_file($imagePathToSave));
     $fileContents = file_get_contents($imagePathToSave);
     unlink($imagePathToSave);
     /** @noinspection PhpUndefinedMethodInspection */
     $this->assertEquals(base64_encode(Image::fromData(Image::fromData(base64_decode($imageRawBase64))->resize(10, 10)->get())->get('png')), base64_encode($fileContents));
 }