Skip to content

Commit

Permalink
updates tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sndsgd committed Apr 26, 2015
1 parent 25ee187 commit 7ab10ef
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 344 deletions.
18 changes: 11 additions & 7 deletions src/writer/AmazonSesWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@
*/
class AmazonSesWriter extends AbstractEmailWriter
{
/**
* {@inheritdoc}
*/
public function write()
{
$client = $this->getSesClient();
$options = $this->getEmailOptions();
$result = $client->sendEmail($options);
}

private function getSesClient()
{
return SesClient::factory([
"profile" => Config::getRequired("amazon.aws.ses.profile"),
"region" => Config::getRequired("amazon.aws.ses.region")
]);

$options = $this->getEmailOptions();
$this->sendEmail($client, $options);
}

private function getEmailOptions()
Expand Down Expand Up @@ -87,5 +86,10 @@ private function getEmailOptions()
"ReturnPath" => $this->getReturnPath()
];
}

private function sendEmail($client, $options)
{
$result = $client->sendEmail($options);
}
}

5 changes: 2 additions & 3 deletions src/writer/FileWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
namespace sndsgd\log\writer;

use \Exception;
use \sndsgd\log\FileInterface;
use \sndsgd\log\Record;
use \sndsgd\Config;
use \sndsgd\Path;
use \sndsgd\log\File;
use \sndsgd\log\Record;


/**
Expand Down
28 changes: 28 additions & 0 deletions tests/FileTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace sndsgd\log;

use \sndsgd\Config;


class FileTest extends \PHPUnit_Framework_TestCase
{

public function testCreateFromLogName()
{
Config::init();

$name = "test";
$expect = File::DEFAULT_DIR."/$name.log";
$file = File::createFromLogName($name);
$this->assertEquals($expect, $file->getPath());

Config::set("sndsgd.log.file.dir", __DIR__);
$expect = __DIR__."/$name.log";
$file = File::createFromLogName($name);
$this->assertEquals($expect, $file->getPath());

Config::init();
}
}

30 changes: 15 additions & 15 deletions tests/RecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ public function setUp()

public function testCreate()
{
$name = 'test';
$message = 'test message';
$name = "test";
$message = "test message";
$r = Record::create($name, $message);
$this->assertInstanceOf('sndsgd\\log\\Record', $r);
$this->assertInstanceOf("sndsgd\\log\\Record", $r);
$this->assertEquals($name, $r->getName());
$this->assertEquals($message, $r->getMessage());
}

public function testSetGetName()
{
$this->r->setName('test');
$this->assertEquals('test', $this->r->getName());
$this->r->setName("test");
$this->assertEquals("test", $this->r->getName());
}

/**
Expand All @@ -41,7 +41,7 @@ public function testSetNameException()
*/
public function testSetNameRegexException()
{
$this->r->setName('asdf 09u132487y9 07 o&YI*(&ty');
$this->r->setName("asdf 09u132487y9 07 o&YI*(&ty");
}

public function testDateAndTimestamp()
Expand All @@ -50,13 +50,13 @@ public function testDateAndTimestamp()
$this->assertTrue(is_float($timestamp));
$this->assertTrue($timestamp < microtime(true));

$date = $this->r->getDate();
$this->assertEquals(date('r', floor($timestamp)), $date);
$date = $this->r->getDate("r");
$this->assertEquals(date("r", $timestamp), $date);
}

public function testSetAndGetMessage()
{
$this->assertEquals('', $this->r->getMessage());
$this->assertEquals("", $this->r->getMessage());
$this->r->setMessage("test \n test ");
$this->assertEquals("test test", $this->r->getMessage());

Expand All @@ -76,22 +76,22 @@ public function testData()
{
$this->assertEquals([], $this->r->getData());

$this->r->addData('one', 1);
$this->assertEquals(['one' => 1], $this->r->getData());
$this->r->addData("one", 1);
$this->assertEquals(["one" => 1], $this->r->getData());

$this->r->addData([
'two' => 2,
'three' => 3
"two" => 2,
"three" => 3
]);
$this->assertEquals(['one'=>1,'two'=>2,'three'=>3], $this->r->getData());
$this->assertEquals(["one"=>1,"two"=>2,"three"=>3], $this->r->getData());
}

/**
* @expectedException InvalidArgumentException
*/
public function testWriteInvalidStringArgument()
{
$this->r->write('invalid');
$this->r->write("invalid");
}

/**
Expand Down
59 changes: 0 additions & 59 deletions tests/file/LogFileTest.php

This file was deleted.

171 changes: 0 additions & 171 deletions tests/file/ReaderTest.php

This file was deleted.

Loading

0 comments on commit 7ab10ef

Please sign in to comment.