Пример #1
0
 /**
  * @dataProvider dataForLogReadingTest
  * @covers Aws\CloudTrail\LogFileReader
  */
 public function testCorrectlyReadsLogFiles($responseBody, $recordCount)
 {
     $s3Client = S3Client::factory(array('key' => 'foo', 'secret' => 'bar'));
     $s3Client->addSubscriber(new MockPlugin(array(new Response(200, null, $responseBody))));
     $reader = new LogFileReader($s3Client);
     $records = $reader->read('test-bucket', 'test-key');
     $this->assertCount($recordCount, $records);
 }
Пример #2
0
 /**
  * Examines the current file in the `logFileIterator` and attempts to read
  * it and load log records from it using the `logFileReader`. This method
  * expects that items pulled from the iterator will take the form:
  *
  *     [
  *         'Bucket' => '...',
  *         'Key'    => '...',
  *     ]
  *
  * @return bool Returns `true` if records were loaded and `false` if no
  *     records were found
  */
 private function loadRecordsFromCurrentLogFile()
 {
     $this->recordIndex = 0;
     $this->records = array();
     $logFile = $this->logFileIterator->current();
     if ($logFile && isset($logFile['Bucket']) && isset($logFile['Key'])) {
         $this->records = $this->logFileReader->read($logFile['Bucket'], $logFile['Key']);
     }
     return (bool) $logFile;
 }