|
- <?php
-
- namespace Tests\Feature;
-
- use App\Kintone\KintoneAccess;
- use App\Kintone\KintoneRecordQuery;
- use App\Kintone\KintoneRecordQueryOperator;
- use App\Kintone\Models\SeasonTicketContract;
- use App\Middlewares\Now;
- use Illuminate\Support\Collection;
- use Tests\TestCase;
-
- class KintoneAccessTest extends TestCase
- {
- public function test_find(): void
- {
- $model = new SeasonTicketContract();
-
- $access = SeasonTicketContract::getAccess();
-
- $access->find(505, $model);
-
- $this->assertEquals("塩山兼司", $model->getStr(SeasonTicketContract::FIELD_CUSTOMER_NAME));
- }
-
- public function test_all(): void
- {
- $model = new SeasonTicketContract();
-
- $access = SeasonTicketContract::getAccess();
-
- $query = SeasonTicketContract::getQuery();
- $query->where(SeasonTicketContract::FIELD_CUSTOMER_NAME, "井出侑加");
- $ret = $access->all($query);
-
- $this->assertEquals(1, $ret->count());
-
-
- /**
- * @var SeasonTicketContract
- */
- $model = $ret[0];
-
- $this->assertEquals("井出侑加", $model->getStr(SeasonTicketContract::FIELD_CUSTOMER_NAME));
-
- $array = $model->toArray();
- $this->assertEquals("井出侑加", $array['customer_name']);
- }
-
-
- // public function test_CarRoom(): void
- // {
-
- // $model = new CarRoom();
-
- // $access = new KintoneAccess(CarRoom::class);
-
- // $access->find(1, $model);
-
- // $this->assertEquals("岩渕パーク", $model->getStr(CarRoom::FIELD_PARK_NAME));
- // $this->assertEquals("5000", $model->getTable(CarRoom::FIELD_TABLE_FEE)[0][CarRoom::FIELD_TABLE_FEE_AMOUNT_PER_MONTH]);
- // $this->assertEquals("自転車", $model->get(CarRoom::FIELD_CAN_USE_VEHICLE_TYPE)[0]);
- // $this->assertEquals("普通自動車", $model->get(CarRoom::FIELD_CAN_USE_VEHICLE_TYPE)[1]);
- // }
-
- // public function test_small()
- // {
- // $model = new Small();
-
- // $access = new KintoneAccess(Small::class);
-
- // $model->set(Small::FIELD_NAME, "iwabuchi");
- // $model->set(Small::FIELD_AGE, "32");
-
- // $res = $access->create($model);
- // $this->assertTrue($res->ok());
- // }
-
- // /**
- // * @group cursor
- // */
- // public function test_cursor()
- // {
- // $access = new KintoneAccess(Small::class);
- // $now = Now::get();
- // $query = Small::query()
- // ->whereIn(Small::FIELD_NAME, ["iwabuchi", "aa"])
- // ->where(Small::FIELD_AGE, 32)
- // ->whereDateTime(Small::FIELD_CREATED_TIME, $now, KintoneRecordQueryOperator::LT);
- // $access->createCursor($query);
- // $ret = $access->next();
-
- // $this->assertTrue($ret instanceof Collection);
- // $this->assertSame(1, $ret->count());
-
- // $this->assertSame("iwabuchi", $ret->first()->getStr(Small::FIELD_NAME));
- // }
-
- // /**
- // * @group cursor
- // */
- // public function test_cursor_all()
- // {
- // $access = new KintoneAccess(Small::class);
- // $now = Now::get();
- // $query = Small::query()
- // ->orderByAsc(Small::FIELD_NAME);
-
- // $ret = $access->all($query, [
- // Small::FIELD_NAME,
- // Small::FIELD_AGE,
- // ]);
-
- // $this->assertTrue($ret instanceof Collection);
- // $this->assertSame(2, $ret->count());
-
- // $first = $ret->first();
- // $this->assertInstanceOf(Small::class, $first);
- // $this->assertSame("iwabuchi", $ret->first()->getStr(Small::FIELD_NAME));
- // $this->assertSame(32, $ret->first()->getNumber(Small::FIELD_AGE));
- // }
- }
|