Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

123 lines
3.6KB

  1. <?php
  2. namespace Tests\Feature;
  3. use App\Kintone\KintoneAccess;
  4. use App\Kintone\KintoneRecordQuery;
  5. use App\Kintone\KintoneRecordQueryOperator;
  6. use App\Kintone\Models\SeasonTicketContract;
  7. use App\Middlewares\Now;
  8. use Illuminate\Support\Collection;
  9. use Tests\TestCase;
  10. class KintoneAccessTest extends TestCase
  11. {
  12. public function test_find(): void
  13. {
  14. $model = new SeasonTicketContract();
  15. $access = SeasonTicketContract::getAccess();
  16. $access->find(505, $model);
  17. $this->assertEquals("塩山兼司", $model->getStr(SeasonTicketContract::FIELD_CUSTOMER_NAME));
  18. }
  19. public function test_all(): void
  20. {
  21. $model = new SeasonTicketContract();
  22. $access = SeasonTicketContract::getAccess();
  23. $query = SeasonTicketContract::getQuery();
  24. $query->where(SeasonTicketContract::FIELD_CUSTOMER_NAME, "井出侑加");
  25. $ret = $access->all($query);
  26. $this->assertEquals(1, $ret->count());
  27. /**
  28. * @var SeasonTicketContract
  29. */
  30. $model = $ret[0];
  31. $this->assertEquals("井出侑加", $model->getStr(SeasonTicketContract::FIELD_CUSTOMER_NAME));
  32. $array = $model->toArray();
  33. $this->assertEquals("井出侑加", $array['customer_name']);
  34. }
  35. // public function test_CarRoom(): void
  36. // {
  37. // $model = new CarRoom();
  38. // $access = new KintoneAccess(CarRoom::class);
  39. // $access->find(1, $model);
  40. // $this->assertEquals("岩渕パーク", $model->getStr(CarRoom::FIELD_PARK_NAME));
  41. // $this->assertEquals("5000", $model->getTable(CarRoom::FIELD_TABLE_FEE)[0][CarRoom::FIELD_TABLE_FEE_AMOUNT_PER_MONTH]);
  42. // $this->assertEquals("自転車", $model->get(CarRoom::FIELD_CAN_USE_VEHICLE_TYPE)[0]);
  43. // $this->assertEquals("普通自動車", $model->get(CarRoom::FIELD_CAN_USE_VEHICLE_TYPE)[1]);
  44. // }
  45. // public function test_small()
  46. // {
  47. // $model = new Small();
  48. // $access = new KintoneAccess(Small::class);
  49. // $model->set(Small::FIELD_NAME, "iwabuchi");
  50. // $model->set(Small::FIELD_AGE, "32");
  51. // $res = $access->create($model);
  52. // $this->assertTrue($res->ok());
  53. // }
  54. // /**
  55. // * @group cursor
  56. // */
  57. // public function test_cursor()
  58. // {
  59. // $access = new KintoneAccess(Small::class);
  60. // $now = Now::get();
  61. // $query = Small::query()
  62. // ->whereIn(Small::FIELD_NAME, ["iwabuchi", "aa"])
  63. // ->where(Small::FIELD_AGE, 32)
  64. // ->whereDateTime(Small::FIELD_CREATED_TIME, $now, KintoneRecordQueryOperator::LT);
  65. // $access->createCursor($query);
  66. // $ret = $access->next();
  67. // $this->assertTrue($ret instanceof Collection);
  68. // $this->assertSame(1, $ret->count());
  69. // $this->assertSame("iwabuchi", $ret->first()->getStr(Small::FIELD_NAME));
  70. // }
  71. // /**
  72. // * @group cursor
  73. // */
  74. // public function test_cursor_all()
  75. // {
  76. // $access = new KintoneAccess(Small::class);
  77. // $now = Now::get();
  78. // $query = Small::query()
  79. // ->orderByAsc(Small::FIELD_NAME);
  80. // $ret = $access->all($query, [
  81. // Small::FIELD_NAME,
  82. // Small::FIELD_AGE,
  83. // ]);
  84. // $this->assertTrue($ret instanceof Collection);
  85. // $this->assertSame(2, $ret->count());
  86. // $first = $ret->first();
  87. // $this->assertInstanceOf(Small::class, $first);
  88. // $this->assertSame("iwabuchi", $ret->first()->getStr(Small::FIELD_NAME));
  89. // $this->assertSame(32, $ret->first()->getNumber(Small::FIELD_AGE));
  90. // }
  91. }