Exemplo n.º 1
0
 /**
  * Make sure we will recieve flatten data from from data_source
  */
 public function test_data_source_interface_implementation()
 {
     $client = new GuzzleHttp\Client();
     $crawler = new InstagramCrawler($client, $this->access_token, ['russia', 'moscow'], [$this->access_token_username, 'applemusic']);
     $data = $crawler->crawl();
     // manually flatten data
     $flatten_data = [];
     foreach ($data['users'] as $media_array) {
         $flatten_data = array_merge($flatten_data, $media_array);
     }
     foreach ($data['tags'] as $media_array) {
         $flatten_data = array_merge($flatten_data, $media_array);
     }
     $this->assertEquals($flatten_data, $crawler->getData());
 }
Exemplo n.º 2
0
 /**
  * Test whole flow:
  * - get data from Instagram
  * - call data source from Poster
  * - post data to Vk
  */
 public function test_flow_posting_from_instagram_to_vk()
 {
     // MOCK HTTP RESPONSES FOR INSTAGRAM
     $mock = new MockHandler([new Response(200, [], file_get_contents(__DIR__ . "/static/lezhnev_user_search.json")), new Response(200, [], file_get_contents(__DIR__ . "/static/user_recent.json"))]);
     $handler = HandlerStack::create($mock);
     $client_mocked_instagram = new Client(['handler' => $handler]);
     // MOCK HTTP RESPONSES FOR VK.COM
     $mock = new MockHandler([new Response(200, [], file_get_contents(__DIR__ . "/static/wall_postponed_0.json"))]);
     $handler = HandlerStack::create($mock);
     $client_mocked_vk = new Client(['handler' => $handler]);
     // Crawl new data
     $dataSource = new InstagramCrawler($client_mocked_instagram, $this->instagram_access_token, [], [$this->instagram_access_token_username]);
     $dataSource->crawl();
     // Pass data to VK poster
     $poster = new VkPoster($this->scheduler, $this->transformer, $dataSource, $this->client, $this->state, $this->access_token, $this->group_id);
     $poster->run();
 }