public function testDataFills()
 {
     $fake = $this->generateFakeData();
     $instance = $this->rebuildTestInstance();
     $property = new \ReflectionProperty($instance, 'attributes');
     $property->setAccessible(true);
     $property->setValue($instance, ['name', 'name1', 'name2']);
     $property->setAccessible(false);
     foreach ($fake as $key => $value) {
         $instance->{$key} = $key === 'name2' ? new Collection() : null;
     }
     $instance->fill($fake);
     foreach ($fake as $key => $value) {
         if ($key !== 'name2') {
             $this->assertSame($fake[$key], $this->testInstance->{$key});
         } else {
             $this->assertTrue($this->testInstance->name2->count() === 3);
         }
     }
     $this->assertSame($fake, $this->testInstance->toArray());
     $this->assertSame($fake, $this->testInstance->toModel());
     $this->assertSame(json_encode($fake), $this->testInstance->toJson());
 }
Exemple #2
0
 /**
  * @test
  */
 public function toArrayReturnsArray()
 {
     $serviceId = 1;
     $name = 'name';
     $note = 'note';
     $status = 'status';
     $gross = 10.0;
     $net = 8.4;
     $taxClass = new \Extcode\Cart\Domain\Model\Order\TaxClass('normal', '19', 0.19);
     $tax = 1.6;
     $this->service->setServiceId($serviceId);
     $this->service->setName($name);
     $this->service->setStatus($status);
     $this->service->setNote($note);
     $this->service->setGross($gross);
     $this->service->setNet($net);
     $this->service->setTax($tax);
     $serviceArr = ['service_id' => $serviceId, 'name' => $name, 'status' => $status, 'net' => $net, 'gross' => $gross, 'tax' => $tax, 'taxClass' => null, 'note' => $note];
     $this->assertEquals($serviceArr, $this->service->toArray());
     //with taxClass
     $this->service->setTaxClass($taxClass);
     $serviceArr['taxClass'] = $taxClass->toArray();
     $this->assertEquals($serviceArr, $this->service->toArray());
 }
 /**
  * @covers ::toArray
  *
  * @expectedException \Drupal\Core\Config\Schema\SchemaIncompleteException
  */
 public function testToArrayFallback()
 {
     $this->entity->toArray();
 }
 /**
  * @covers ::toArray
  *
  * @expectedException \Drupal\Core\Config\Schema\SchemaIncompleteException
  */
 public function testToArrayFallback()
 {
     $this->entityType->expects($this->any())->method('getPropertiesToExport')->willReturn([]);
     $this->entity->toArray();
 }
 /**
  * @test
  */
 public function toArrayReturnsEmptyArrayWithForEmptyQueue()
 {
     $this->assertSame(array(), $this->flashMessageQueue->toArray());
 }