Skip to content

Commit

Permalink
Merge pull request #47 from ThePhalcons/2.1.0
Browse files Browse the repository at this point in the history
AWS service unit tests
  • Loading branch information
CodeIsLife authored and CodeIsLife committed Jan 23, 2016
2 parents 1436817 + 30d71ab commit 7edb7f7
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 16 deletions.
64 changes: 64 additions & 0 deletions Tests/Services/SESMailingServiceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* Created by PhpStorm.
* User: elmehdi
* Date: 23/01/16
* Time: 03:42
*/

/**
* Class SESMailingServiceTest
*
*/
class SESMailingServiceTest extends PHPUnit_Framework_TestCase
{

/**
* test if SES service exists
*/
public function testSESInjection()
{
$client = $this->createClient();
$ses = $client->getContainer()->get('amazon_SES');
assert( $ses !== null, 'SES is not defined');
}

/**
* tests if verified email address exist in global config
*/
public function testMailingServiceInjection()
{
$client = $this->createClient();
$mailer = $client->getContainer()->get('ws.service.mailing');
assert( $mailer !== null, 'Mailing Service injection is not working');
assert( $mailer instanceof MailingService, 'given Object is not an instance of MailingService');
}

public function testSendMail()
{
$client = $this->createClient();
/**@var $mailer MailingService */
$mailer = $client->getContainer()->get('ws.service.mailing');
$mailer->setSubject('Drivy UNIT TEST')
->addToAddress('[email protected]')
->setMessage('UNIT TEST is working');
$result = $mailer->sendEmail();

var_dump($result);
assert(true === true, "todo");
}

public function testListVerifiedEmailsAddresses()
{
$client = $this->createClient();
/**@var $ses SesClient */

$ses = $client->getContainer()->get('amazon_SES');

$list = $ses->listVerifiedEmailAddresses(array());

// TODO :
assert(true == true, 'source email is not verified');


}
45 changes: 45 additions & 0 deletions Tests/Services/StorageServiceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

/**
* Class StorageServiceTest
*
* @package Core\WSBundle\Tests\Service
*
* @Author : El Mehdi Mouddene <[email protected]>
*
* Initial version created on: 23/01/16 23:59
*
*/

class StorageServiceTest extends WebTestCase
{

public function testServiceInjection(){
$client = $this->createClient();
$s3 = $client->getContainer()->get('amazon_S3');
assert( $s3 !== null, 'Requested service unavailble');
}

public function testDoesContainerHasUploadBucketParameter(){
$client = $this->createClient();
assert($client->getContainer()->hasParameter('the_phalcons_amazon_web_services.services.S3.bucket') === true, "Container hasn't the_phalcons_amazon_web_services.services.S3.bucket parameter");
}

public function testCreateBucket(){
/** @var S3Client $client */
$client = $this->createClient();
$client->createBucket(array(
'Bucket' => 'mybucket',
'LocationConstraint' => 'us-west-2',
));

assert($client->doesBucketExist("mybucket") === true, "bucket doesn't exist !!!")
$client->deleteBucket(array(
'Bucket' => 'mybucket',
'LocationConstraint' => 'us-west-2',
));

assert($client->doesBucketExist("mybucket") === false, "bucket hasn't been deleted !!!")
}

}
23 changes: 7 additions & 16 deletions aws.config.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,32 @@

thephalcons_amazon_web_services:
enable_extensions: false
# for stream wrapper use : [S3, SES ...]
enable_extensions: []
credentials:
key: <YOUR APP KEY>
secret: <YOUT APP SECRET>
shared_config:
region: 'eu_west_1'
region: %aws_region%
version: %aws_version%
account_id: %aws_account_id%
canonical_id: %aws_canonical_id%
canonical_name: %aws_canonical_name%
mfa_serial: %aws_mfa_serial%
cloudfront_keypair: %aws_cloudfront_keypair%
cloudfront_pem: %aws_cloudfront_pem%
default_cache_config: null
enable_extensions: []
certificate_authority: false
disable_auto_config: false
services:
#For each service you want to inject:
#add service name exp :
#SQS:
#set to true if you'ill use it as service in your code
#false for global config
#injectable: true

S3:
#injectable set to true means that the wrapper service will be injected in runtime
injectable: true
bucket: <YOUR BUCKET NAME>
#... add all used bucket like assets bucket or upload bucket, can be accessed
# using container in your code
# example $container->getParameter('services.S3.{key}')
CloudFront:
injectable: false
#asset_distribution: http://d2aqddmeyyyfie.cloudfront.net
web_distribution: http://xxxxxxxxxxxxxx.cloudfront.net
#upload_distribution: http://xxxxxxxxxxxxxx.cloudfront.net
SES:
injectable: true
verified_addresse: <YOUR Verified @>
#for more information how to use SES service
#http://docs.aws.amazon.com/aws-sdk-php/v2/guide/service-ses.html
#verified_addresse: <YOUR Verified @>

0 comments on commit 7edb7f7

Please sign in to comment.