| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace Ipol\DPD\Tests;
- use \Ipol\DPD\API\User\User as API;
- use Ipol\DPD\Config\Config;
- use Ipol\DPD\DB\Connection;
- use Ipol\DPD\DB\Location\Agent;
- use Ipol\DPD\DB\Location\Table;
- use PHPUnit\Framework\TestCase;
- class AgentTest extends TestCase
- {
- public function test_can_load_all()
- {
- $config = new Config([
- 'DB' =>[
- 'DSN' => 'sqlite:'. __TEST_DIR__ .'/test.db',
- 'USERNAME' => '',
- 'PASSWORD' => '',
- 'DRIVER' => null,
- 'PDO' => null,
- ]
- ]);
- $api = API::getInstanceByConfig($config);
- /** @var Table $locationTable */
- $locationTable = Connection::getInstance($config)->getTable('location');
- $locationLoader = new Agent($api, $locationTable);
- $locationLoader->loadAll();
- $expectedCount = count(file(__TEST_DIR__ .'/../data/cities.csv'));
- $actualCount = count($locationTable->find()->fetchAll());
- $this->assertEquals($expectedCount, $actualCount);
- }
- public function test_can_load_cash_pay()
- {
- $config = new Config([
- 'DB' =>[
- 'DSN' => 'sqlite:'. __TEST_DIR__ .'/test.db',
- 'USERNAME' => '',
- 'PASSWORD' => '',
- 'DRIVER' => null,
- 'PDO' => null,
- ],
- 'IS_TEST' => true,
- 'KLIENT_NUMBER' => '1052000804',
- 'KLIENT_KEY' => 'C720C102732A855232BB7BA8D6AFF9B781F9E2F6'
- ]);
- $api = API::getInstanceByConfig($config);
- $locationTable = Connection::getInstance($config)->getTable('location');
- $locationLoader = new Agent($api, $locationTable);
- $locationLoader->loadCashPay();
- }
- }
|