Esempio n. 1
0
 public function testGetIndexedDocumentDataReturnsStringDates()
 {
     $model = new TestEntity();
     $model->date = \Carbon\Carbon::create();
     $indexData = $model->getIndexDocumentData();
     $this->assertInternalType('string', $indexData['date']);
 }
Esempio n. 2
0
 public function testValidAdd()
 {
     $entity = new TestEntity();
     $collection = $entity->newCollection();
     $collection->add($entity);
     $this->assertInstanceOf(TestEntity::class, $collection->first());
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     if (env('APP_ENV') !== 'spira-core-testing') {
         return true;
     }
     Schema::drop(TestEntity::getTableName());
 }
Esempio n. 4
0
 /**
  * No abstract static methods
  * So we make small coverage hack here.
  */
 public function testCoverageStatic()
 {
     TestEntity::createCustomIndexes();
     TestEntity::deleteCustomIndexes();
 }
Esempio n. 5
0
 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());
 }
Esempio n. 6
0
 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);
 }