コード例 #1
0
ファイル: ModelTest.php プロジェクト: spira/api-core
 public function testGetIndexedDocumentDataReturnsStringDates()
 {
     $model = new TestEntity();
     $model->date = \Carbon\Carbon::create();
     $indexData = $model->getIndexDocumentData();
     $this->assertInternalType('string', $indexData['date']);
 }
コード例 #2
0
 public function testValidAdd()
 {
     $entity = new TestEntity();
     $collection = $entity->newCollection();
     $collection->add($entity);
     $this->assertInstanceOf(TestEntity::class, $collection->first());
 }
コード例 #3
0
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     if (env('APP_ENV') !== 'spira-core-testing') {
         return true;
     }
     Schema::drop(TestEntity::getTableName());
 }
コード例 #4
0
ファイル: ElasticSearchTest.php プロジェクト: spira/api-core
 /**
  * No abstract static methods
  * So we make small coverage hack here.
  */
 public function testCoverageStatic()
 {
     TestEntity::createCustomIndexes();
     TestEntity::deleteCustomIndexes();
 }
コード例 #5
0
ファイル: ChildEntityTest.php プロジェクト: spira/api-core
 public function testDeleteManyInvalidId()
 {
     $entity = factory(TestEntity::class)->create();
     $this->addRelatedEntities($entity);
     $childCount = TestEntity::find($entity->entity_id)->testMany->count();
     $childEntities = $entity->testMany;
     $childEntities->first()->entity_id = (string) Uuid::uuid4();
     $childEntities->last()->entity_id = (string) Uuid::uuid4();
     $data = array_map(function ($entity) {
         return ['entityId' => $entity->entity_id, 'value' => 'foobar'];
     }, $childEntities->all());
     $this->withAuthorization()->deleteJson('/test/entities/' . $entity->entity_id . '/children', $data);
     $object = json_decode($this->response->getContent());
     $this->assertTrue(is_array($object->invalid));
     $this->assertObjectHasAttribute('entityId', $object->invalid[0]);
     $this->assertNull($object->invalid[1]);
     $this->assertObjectHasAttribute('entityId', $object->invalid[4]);
     $this->assertEquals('The selected entity id is invalid.', $object->invalid[0]->entityId[0]->message);
     $this->assertEquals($childCount, TestEntity::find($entity->entity_id)->testMany->count());
 }
コード例 #6
0
ファイル: EntityTest.php プロジェクト: spira/api-core
 public function testEntitySearch()
 {
     TestEntity::removeAllFromIndex();
     $searchEntity = factory(TestEntity::class)->create(['varchar' => 'searchforthisstring']);
     sleep(1);
     //give the elastic search agent time to index
     $this->getJson('/test/entities/pages?q=searchforthisstring', ['Range' => 'entities=0-9']);
     $collection = json_decode($this->response->getContent());
     $this->assertResponseStatus(206);
     $this->shouldReturnJson();
     $this->assertJsonArray();
     $this->assertCount(1, $collection);
     $this->assertEquals($searchEntity->entity_id, $collection[0]->entityId);
 }