public function isIdentical(self $parameters) { return $this->toArray() == $parameters->toArray(); }
/** * Create a stack model from the stack portion of a CloudFormation API * DescribeStacks response. * * @return Stack|null Model representing the stack, or null if the response * did not have a template and environment tag. */ protected function createFromApiResponse(array $response) { PHPUnit_Framework_Assert::assertArrayHasKey('StackId', $response, 'Stack portion of CloudFormation API response must contain a "StackId" key'); PHPUnit_Framework_Assert::assertArrayHasKey('StackName', $response, 'Stack portion of CloudFormation API response must contain a "StackName" key'); PHPUnit_Framework_Assert::assertArrayHasKey('StackStatus', $response, 'Stack portion of CloudFormation API response must contain a "StackStatus" key'); PHPUnit_Framework_Assert::assertArrayHasKey('Parameters', $response, 'Stack portion of CloudFormation API response must contain a "Parameters" key'); PHPUnit_Framework_Assert::assertArrayHasKey('Tags', $response, 'Stack portion of CloudFormation API response must contain a "Tags" key'); PHPUnit_Framework_Assert::assertArrayHasKey('CreationTime', $response, 'Stack portion of CloudFormation API response must contain a "CreationTime" key'); foreach ($response['Tags'] as $tag) { PHPUnit_Framework_Assert::assertArrayHasKey('Key', $tag, 'Tags portion of CloudFormation API response must contain a "Key" key'); PHPUnit_Framework_Assert::assertArrayHasKey('Value', $tag, 'Tags portion of CloudFormation API response must contain a "Value" key'); if ($tag['Key'] === Stack::TEMPLATE_TAG) { $templateName = $tag['Value']; } elseif ($tag['Key'] === Stack::ENVIRONMENT_TAG) { $environment = $tag['Value']; } } if (!isset($templateName) || !isset($environment)) { return null; } // Get the stack name from API response, for if its case has been normalised. $name = $response['StackName']; // The stack template may contain sub-stacks as URLs, expand these so // we have a complete representation of the stack. $templateExpansionService = $this->templateExpansionService; $cloudFormation = $this->cloudFormation; $templateBodyCallback = function () use($name, $templateExpansionService, $cloudFormation) { return $templateExpansionService->getExpandedTemplateBody($cloudFormation->GetTemplate(['StackName' => $name])['TemplateBody']); }; // LastUpdatedTime is not set if the stack has never been updated, but // for our purposes it is equivalent to the CreationTime in such case. if (!isset($response['LastUpdatedTime'])) { $response['LastUpdatedTime'] = $response['CreationTime']; } return new Stack($name, $environment, new Template($templateName, $templateBodyCallback), Parameters::newFromCloudFormationResponseElement($response['Parameters']), $response['StackId'], $response['StackStatus'], new DateTime($response['CreationTime']), new DateTime($response['LastUpdatedTime'])); }
public function testIsNotIdentical() { $modelA = new Parameters(['Foo' => 'Bar']); $modelB = new Parameters(['Baz' => 'Qux']); $this->assertFalse($modelA->isIdentical($modelB)); }