/**
  * @test
  */
 public function loadLines()
 {
     $fileProvider = new FileProvider(self::FILE);
     $results = [];
     foreach ($fileProvider->load() as $value) {
         $results[] = $value;
     }
     $this->assertEquals(4, count($results));
 }
Beispiel #2
0
<?php

/**
 * Created by PhpStorm.
 * User: c3zi
 * Date: 16/06/15
 * Time: 21:05
 */
require_once __DIR__ . '/vendor/autoload.php';
use PhpAmqpLib\Connection\AMQPConnection;
use PhpAmqpLib\Message\AMQPMessage;
use DataAggregator\InputProvider\FileProvider;
$path = __DIR__ . '/data/facebook_contacts.txt';
try {
    $fileProvider = new FileProvider($path);
} catch (\InvalidArgumentException $ex) {
    print sprintf("Some probles with file: %s\n", $path);
    die;
}
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();
//$channel->queue_declare('task_aggregator3', false, true, false, false);
foreach ($fileProvider->load() as $contact) {
    $msg = new AMQPMessage($contact, array('delivery_mode' => 2));
    $channel->basic_publish($msg, '', 'task_aggregator3');
}
print sprintf("\n [x] Sent contacts from file: %s\n", $path);
$channel->close();
$connection->close();