/** * Creates a tag for an organization-site relationship * * @param string $tag Name of tag to create * @return Tag $this->models[$tag] The newly created tag */ public function create($tag) { $params = [$tag => ['sites' => [$this->org_site_membership->getSite()->id]]]; $this->request->request("organizations/{$this->org_site_membership->organization->id}/tags", ['method' => 'put', 'form_params' => $params]); $this->models[$tag] = $this->getContainer()->get($this->collected_class, [(object) ['id' => $tag], ['collection' => $this]]); return $this->models[$tag]; }
/** * 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); }
public function testDelete() { $site_data = ['site_id' => '123']; $container = new Container(); $site = $this->getMockBuilder(Site::class)->disableOriginalConstructor()->getMock(); $site->method('get')->with('id')->willReturn('123'); $container->add(Site::class, $site); $container->add(Tags::class); $org = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock(); $workflows = $this->getMockBuilder(Workflows::class)->disableOriginalConstructor()->getMock(); $wf = $this->getMockBuilder(Workflow::class)->disableOriginalConstructor()->getMock(); $workflows->expects($this->once())->method('create')->with('remove_organization_site_membership', ['params' => ['site_id' => '123']])->willReturn($wf); $org->method('getWorkflows')->willReturn($workflows); $org_site = new OrganizationSiteMembership((object) ['site' => (object) $site_data, 'tags' => (object) []], ['collection' => (object) ['organization' => $org]]); $org_site->setContainer($container); $out = $org_site->delete(); $this->assertEquals($wf, $out); }