/** * Options constructor. * * @param OptionsBuilder $builder */ public function __construct(OptionsBuilder $builder) { $this->collapseKey = $builder->getCollapseKey(); $this->priority = $builder->getPriority(); $this->contentAvailable = $builder->isContentAvailable(); $this->delayWhileIdle = $builder->isDelayWhileIdle(); $this->timeToLive = $builder->getTimeToLive(); $this->restrictedPackageName = $builder->getRestrictedPackageName(); $this->isDryRun = $builder->isDryRun(); }
/** * @test */ public function it_construct_a_valid_json_with_option() { $targetPartial = '{ "collapse_key":"collapseKey", "content_available":true }'; $targetFull = '{ "collapse_key":"collapseKey", "content_available":true, "priority":"high", "delay_while_idle":true, "time_to_live":200, "restricted_package_name":"customPackageName", "dry_run": true }'; $optionBuilder = new OptionsBuilder(); $optionBuilder->setCollapseKey("collapseKey"); $optionBuilder->setContentAvailable(true); $json = json_encode($optionBuilder->build()->toArray()); $this->assertJsonStringEqualsJsonString($targetPartial, $json); $optionBuilder->setPriority(OptionsPriorities::high)->setDelayWhileIdle(true)->setDryRun(true)->setRestrictedPackageName("customPackageName")->setTimeToLive(200); $json = json_encode($optionBuilder->build()->toArray()); $this->assertJsonStringEqualsJsonString($targetFull, $json); }