ConnectionTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Tioncico
  5. * Date: 2019/10/22 0022
  6. * Time: 10:19
  7. */
  8. namespace EasySwoole\ORM\Tests;
  9. use EasySwoole\Mysqli\Client;
  10. use EasySwoole\Mysqli\QueryBuilder;
  11. use EasySwoole\ORM\Db\Config;
  12. use EasySwoole\ORM\Db\Connection;
  13. use EasySwoole\ORM\Db\MysqlPool;
  14. use EasySwoole\ORM\Db\Result;
  15. use PHPUnit\Framework\TestCase;
  16. class ConnectionTest extends TestCase
  17. {
  18. /**
  19. * @var $connection Connection
  20. */
  21. protected $connection;
  22. function setUp(): void
  23. {
  24. parent::setUp(); // TODO: Change the autogenerated stub
  25. $config = new Config(MYSQL_CONFIG);
  26. $this->connection = new Connection($config);
  27. }
  28. function testQuery()
  29. {
  30. $queryBuild = new QueryBuilder();
  31. $queryBuild->raw("show tables");
  32. $data = $this->connection->defer()->query($queryBuild);
  33. $this->assertTrue($data instanceof Result);
  34. }
  35. // getPool变更为受保护 不再测试
  36. // function testGetPool(){
  37. // /**
  38. // * @var $data MysqlPool
  39. // */
  40. // $data = $this->connection->getPool();
  41. // $this->assertTrue($data instanceof MysqlPool);
  42. // /**
  43. // * @var $mysqli Client
  44. // */
  45. // $mysqli = $data->getObj();
  46. // $queryBuild = new QueryBuilder();
  47. // $queryBuild->raw("show tables");
  48. //
  49. // $data = $mysqli->rawQuery('show tables');
  50. // $this->assertIsArray($data);
  51. // }
  52. }