/** * */ public function testFetchWithLogs() { $data = ['id' => 'workflow_id']; $site = new Site((object) ['id' => 'site_id']); $environments = new Environments(['site' => $site]); $env = new Environment((object) ['id' => 'env_id'], ['collection' => $environments]); $user = new User((object) ['id' => 'user_id']); $org = new Organization((object) ['id' => 'org_id']); $this->workflow = new Workflow((object) $data, ['environment' => $env]); $this->request->expects($this->at(0))->method('request')->with('sites/site_id/workflows/workflow_id', ['options' => ['method' => 'get'], 'query' => ['hydrate' => 'operations_with_logs']])->willReturn(['data' => ['baz' => '123']]); $this->workflow->setRequest($this->request); $this->workflow->fetchWithLogs(); $this->workflow = new Workflow((object) $data, ['site' => $site]); $this->request->expects($this->at(0))->method('request')->with('sites/site_id/workflows/workflow_id', ['options' => ['method' => 'get'], 'query' => ['hydrate' => 'operations_with_logs']])->willReturn(['data' => ['baz' => '123']]); $this->workflow->setRequest($this->request); $this->workflow->fetchWithLogs(); $this->workflow = new Workflow((object) $data, ['user' => $user]); $this->request->expects($this->at(0))->method('request')->with('users/user_id/workflows/workflow_id', ['options' => ['method' => 'get'], 'query' => ['hydrate' => 'operations_with_logs']])->willReturn(['data' => ['baz' => '123']]); $this->workflow->setRequest($this->request); $this->workflow->fetchWithLogs(); $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); $session->expects($this->once())->method('getUser')->willReturn($user); $this->workflow = new Workflow((object) $data, ['organization' => $org]); $this->request->expects($this->at(0))->method('request')->with('users/user_id/organizations/org_id/workflows/workflow_id', ['options' => ['method' => 'get'], 'query' => ['hydrate' => 'operations_with_logs']])->willReturn(['data' => ['baz' => '123']]); $this->workflow->setSession($session); $this->workflow->setRequest($this->request); $this->workflow->fetchWithLogs(); }
/** * Tests the org:site:remove command */ public function testRemove() { $org_name = 'Organization Name'; $site_name = 'Site Name'; $this->workflow = $this->getMockBuilder(Workflow::class)->disableOriginalConstructor()->getMock(); $this->org_site_membership->expects($this->once())->method('delete')->with()->willReturn($this->workflow); $this->workflow->expects($this->once())->method('checkProgress')->willReturn(true); $this->site->expects($this->once())->method('get')->with($this->equalTo('name'))->willReturn($site_name); $this->organization->expects($this->once())->method('get')->with($this->equalTo('profile'))->willReturn((object) ['name' => $org_name]); $this->logger->expects($this->once())->method('log')->with($this->equalTo('notice'), $this->equalTo('{site} has been removed from the {org} organization.'), $this->equalTo(['site' => $site_name, 'org' => $org_name])); $out = $this->command->remove($this->organization->id, $this->site->id); $this->assertNull($out); }
/** * @inheritdoc */ public function setUp() { parent::setUp(); $this->workflow = $this->getMockBuilder(Workflow::class)->disableOriginalConstructor()->getMock(); // workflow succeeded $this->workflow->expects($this->once())->method('checkProgress')->with()->willReturn(true); $this->workflow->expects($this->once())->method('getMessage')->with()->willReturn('successful workflow'); $this->environment->expects($this->once())->method('setHttpsCertificate')->with(['cert' => '*CERT*', 'key' => '*KEY*', 'intermediary' => '*INT*'])->willReturn($this->workflow); // should display a notice about the mode switch $this->logger->expects($this->at(0))->method('log')->with($this->equalTo('notice'), $this->equalTo('SSL certificate updated. Converging loadbalancer.')); $this->logger->expects($this->at(1))->method('log')->with($this->equalTo('notice'), $this->equalTo('successful workflow')); $this->command = new SetCommand(); $this->command->setSites($this->sites); $this->command->setLogger($this->logger); }