Ejemplo n.º 1
0
 /**
  * @param \RCatlin\LearnPHPSpec\Brand $brand
  * @param \RCatlin\LearnPHPSpec\Serialize\BrandSerializer $brandSerializer
  */
 public function it_serializes(Brand $brand, BrandSerializer $brandSerializer)
 {
     // Model returns Brand
     $this->model->getBrand()->willReturn($brand);
     $this->model->getName()->willReturn('model name');
     $this->model->getYear()->willReturn(2017);
     // SerializerFactory returns BrandSerializer
     $this->factory->get($brand)->willReturn($brandSerializer);
     // Brand Serializer returns an empty array
     $brandSerializer->serialize()->willReturn([]);
     $this->serialize()->shouldReturn(['brand' => [], 'name' => 'model name', 'year' => 2017]);
 }
Ejemplo n.º 2
0
 public function it_serializes(Brand $brand, BrandSerializer $brandSerializer)
 {
     $this->wheels->getCount()->willReturn(4);
     $this->wheels->getDiameter()->willReturn(28.75);
     // Wheels returns Brand
     $this->wheels->getBrand()->willReturn($brand);
     // SerializerFactory returns BrandSerializer
     $this->factory->get($brand)->willReturn($brandSerializer);
     // BrandSerializer returns an empty array
     $brandSerializer->serialize()->willReturn([]);
     $this->serialize()->shouldReturn(['count' => 4, 'brand' => [], 'diameter' => 28.75]);
 }
Ejemplo n.º 3
0
 /**
  * @param \RCatlin\LearnPHPSpec\Color $color
  * @param \RCatlin\LearnPHPSpec\Serialize\ColorSerializer $colorSerializer
  * @param \RCatlin\LearnPHPSpec\Doors $doors
  * @param \RCatlin\LearnPHPSpec\Serialize\DoorsSerializer $doorsSerializer
  * @param \RCatlin\LearnPHPSpec\Engine $engine
  * @param \RCatlin\LearnPHPSpec\Serialize\EngineSerializer $engineSerializer
  * @param \RCatlin\LearnPHPSpec\Model $model
  * @param \RCatlin\LearnPHPSpec\Serialize\ModelSerializer $modelSerializer
  * @param \RCatlin\LearnPHPSpec\Wheels $wheels
  * @param \RCatlin\LearnPHPSpec\Serialize\WheelsSerializer $wheelsSerializer
  */
 public function it_serializes(Color $color, ColorSerializer $colorSerializer, Doors $doors, DoorsSerializer $doorsSerializer, Engine $engine, EngineSerializer $engineSerializer, Model $model, ModelSerializer $modelSerializer, Wheels $wheels, WheelsSerializer $wheelsSerializer)
 {
     // Car returns mocked objects
     $this->car->getColor()->willReturn($color);
     $this->car->getDoors()->willReturn($doors);
     $this->car->getEngine()->willReturn($engine);
     $this->car->getModel()->willReturn($model);
     $this->car->getWheels()->willReturn($wheels);
     // SerializerFactory#get returns Serializers
     $this->factory->get($color)->willReturn($colorSerializer);
     $this->factory->get($doors)->willReturn($doorsSerializer);
     $this->factory->get($engine)->willReturn($engineSerializer);
     $this->factory->get($model)->willReturn($modelSerializer);
     $this->factory->get($wheels)->willReturn($wheelsSerializer);
     // Serializers#serialize return arrays
     $colorSerializer->serialize()->willReturn(['color']);
     $doorsSerializer->serialize()->willReturn(['doors']);
     $engineSerializer->serialize()->willReturn(['engine']);
     $modelSerializer->serialize()->willReturn(['model']);
     $wheelsSerializer->serialize()->willReturn(['wheels']);
     $this->serialize()->shouldReturn(['color' => ['color'], 'doors' => ['doors'], 'engine' => ['engine'], 'model' => ['model'], 'wheels' => ['wheels']]);
 }