Pantheon\Terminus\UnitTests\Collections\WorkflowsTest::testCreate PHP Method

testCreate() public method

public testCreate ( )
    public function testCreate()
    {
        $type = "test";
        $model_data = (object) ['id' => 'a'];
        $params = ['a' => '1', 'b' => 2];
        $this->request->expects($this->once())->method('request')->with('TESTURL', ['method' => 'post', 'form_params' => ['type' => $type, 'params' => (object) $params]])->willReturn(['data' => $model_data]);
        $workflows = $this->getMockBuilder(Workflows::class)->disableOriginalConstructor()->setMethods(['getUrl', 'add'])->getMock();
        $workflows->expects($this->once())->method('getURl')->willReturn('TESTURL');
        $options = ['id' => $model_data->id, 'collection' => $workflows];
        $model = new Workflow($model_data, $options);
        $this->container->expects($this->at(0))->method('get')->with(Workflow::class, [$model_data, $options])->willReturn($model);
        $workflows->expects($this->once())->method('add')->willReturn($model);
        $workflows->setRequest($this->request);
        $workflows->setContainer($this->container);
        $workflows->create('test', ['params' => $params]);
    }