AgentTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace Ipol\DPD\Tests;
  3. use \Ipol\DPD\API\User\User as API;
  4. use Ipol\DPD\Config\Config;
  5. use Ipol\DPD\DB\Connection;
  6. use Ipol\DPD\DB\Location\Agent;
  7. use Ipol\DPD\DB\Location\Table;
  8. use PHPUnit\Framework\TestCase;
  9. class AgentTest extends TestCase
  10. {
  11. public function test_can_load_all()
  12. {
  13. $config = new Config([
  14. 'DB' =>[
  15. 'DSN' => 'sqlite:'. __TEST_DIR__ .'/test.db',
  16. 'USERNAME' => '',
  17. 'PASSWORD' => '',
  18. 'DRIVER' => null,
  19. 'PDO' => null,
  20. ]
  21. ]);
  22. $api = API::getInstanceByConfig($config);
  23. /** @var Table $locationTable */
  24. $locationTable = Connection::getInstance($config)->getTable('location');
  25. $locationLoader = new Agent($api, $locationTable);
  26. $locationLoader->loadAll();
  27. $expectedCount = count(file(__TEST_DIR__ .'/../data/cities.csv'));
  28. $actualCount = count($locationTable->find()->fetchAll());
  29. $this->assertEquals($expectedCount, $actualCount);
  30. }
  31. public function test_can_load_cash_pay()
  32. {
  33. $config = new Config([
  34. 'DB' =>[
  35. 'DSN' => 'sqlite:'. __TEST_DIR__ .'/test.db',
  36. 'USERNAME' => '',
  37. 'PASSWORD' => '',
  38. 'DRIVER' => null,
  39. 'PDO' => null,
  40. ],
  41. 'IS_TEST' => true,
  42. 'KLIENT_NUMBER' => '',
  43. 'KLIENT_KEY' => ''
  44. ]);
  45. $api = API::getInstanceByConfig($config);
  46. $locationTable = Connection::getInstance($config)->getTable('location');
  47. $locationLoader = new Agent($api, $locationTable);
  48. $locationLoader->loadCashPay();
  49. }
  50. }