Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'cs/various-things' of https://github.com/Maks3w/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Jul 12, 2012
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 67 deletions.
2 changes: 1 addition & 1 deletion src/Filter/Regex.php
Expand Up @@ -54,7 +54,7 @@ public function filter(array $event)
{
$message = $event['message'];
if (is_array($event['message'])) {
$message = var_export($message, TRUE);
$message = var_export($message, TRUE);
}
return preg_match($this->regex, $message) > 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/Validator.php
Expand Up @@ -42,7 +42,7 @@ public function __construct(ZendValidator $validator)
* Returns TRUE to accept the message, FALSE to block it.
*
* @param array $event event data
* @return boolean
* @return boolean
*/
public function filter(array $event)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Formatter/ErrorHandler.php
Expand Up @@ -20,14 +20,14 @@
class ErrorHandler implements FormatterInterface
{
const DEFAULT_FORMAT = '%timestamp% %priorityName% (%priority%) %message% (errno %extra[errno]%) in %extra[file]% on line %extra[line]%';

/**
* Format
*
* @var string
*
* @var string
*/
protected $format;

/**
* Class constructor
*
Expand Down
4 changes: 2 additions & 2 deletions src/Formatter/ExceptionHandler.php
Expand Up @@ -47,9 +47,9 @@ public function format($event)

/**
* Get the type of a function
*
*
* @param string $type
* @return string
* @return string
*/
protected function getType($type)
{
Expand Down
42 changes: 21 additions & 21 deletions src/Writer/Db.php
Expand Up @@ -30,8 +30,8 @@ class Db extends AbstractWriter

/**
* Table name
*
* @var string
*
* @var string
*/
protected $tableName;

Expand All @@ -44,17 +44,17 @@ class Db extends AbstractWriter

/**
* Field separator for sub-elements
*
* @var string
*
* @var string
*/
protected $separator = '_';

/**
* Constructor
*
* We used the Adapter instead of Zend\Db for a performance reason.
*
* @param Adapter $db
*
* @param Adapter $db
* @param string $tableName
* @param array $columnMap
* @param string $separator
Expand All @@ -66,11 +66,11 @@ public function __construct(Adapter $db, $tableName, array $columnMap = null, $s
if ($db === null) {
throw new Exception\InvalidArgumentException('You must pass a valid Zend\Db\Adapter\Adapter');
}

$this->db = $db;
$this->tableName = $tableName;
$this->columnMap = $columnMap;

if (!empty($separator)) {
$this->separator = $separator;
}
Expand Down Expand Up @@ -120,34 +120,34 @@ protected function doWrite(array $event)

$statement = $this->db->query($this->prepareInsert($this->db, $this->tableName, $dataToInsert));
$statement->execute($dataToInsert);

}

/**
* Prepare the INSERT SQL statement
*
*
* @param Adapter $db
* @param string $tableName
* @param array $fields
* @return string
* @return string
*/
protected function prepareInsert(Adapter $db, $tableName, array $fields)
{
protected function prepareInsert(Adapter $db, $tableName, array $fields)
{
$sql = 'INSERT INTO ' . $db->platform->quoteIdentifier($tableName) . ' (' .
implode(",",array_map(array($db->platform, 'quoteIdentifier'), $fields)) . ') VALUES (' .
implode(",",array_map(array($db->driver, 'formatParameterName'), $fields)) . ')';

return $sql;
}

/**
* Map event into column using the $columnMap array
*
*
* @param array $event
* @param array $columnMap
* @return array
* @return array
*/
protected function mapEventIntoColumn(array $event, array $columnMap = null)
protected function mapEventIntoColumn(array $event, array $columnMap = null)
{
if (empty($event)) {
return array();
Expand All @@ -163,18 +163,18 @@ protected function mapEventIntoColumn(array $event, array $columnMap = null)
}
} elseif (isset($columnMap[$name])) {
$data[$columnMap[$name]] = $value;
}
}
}
return $data;
}

/**
* Transform event into column for the db table
*
*
* @param array $event
* @return array
* @return array
*/
protected function eventIntoColumn(array $event)
protected function eventIntoColumn(array $event)
{
if (empty($event)) {
return array();
Expand Down
4 changes: 2 additions & 2 deletions src/Writer/Mail.php
Expand Up @@ -24,7 +24,7 @@
* completion, so any log entries accumulated are sent in a single email.
* The email is sent using a Zend\Mail\Transport\TransportInterface object
* (Sendmail is default).
*
*
* @category Zend
* @package Zend_Log
* @subpackage Writer
Expand Down Expand Up @@ -72,7 +72,7 @@ class Mail extends AbstractWriter

/**
* Constructor
*
*
* @param MailMessage $mail
* @param Transport\TransportInterface $transport Optional
* @return Mail
Expand Down
6 changes: 3 additions & 3 deletions src/WriterPluginManager.php
Expand Up @@ -21,7 +21,7 @@ class WriterPluginManager extends AbstractPluginManager
{
/**
* Default set of writers
*
*
* @var array
*/
protected $invokableClasses = array(
Expand All @@ -39,8 +39,8 @@ class WriterPluginManager extends AbstractPluginManager
* Validate the plugin
*
* Checks that the writer loaded is an instance of Writer\WriterInterface.
*
* @param mixed $plugin
*
* @param mixed $plugin
* @return void
* @throws Exception\InvalidArgumentException if invalid
*/
Expand Down
2 changes: 1 addition & 1 deletion test/Filter/ValidatorTest.php
Expand Up @@ -32,7 +32,7 @@ public function testValidatorFilter()
$this->assertFalse($filter->filter(array('message' => 'test123')));
$this->assertFalse($filter->filter(array('message' => '(%$')));
}

public function testValidatorChain()
{
$validatorChain = new ValidatorChain();
Expand Down
2 changes: 1 addition & 1 deletion test/Formatter/SimpleTest.php
Expand Up @@ -84,7 +84,7 @@ function testComplexValues()
$line = $f->format($fields);
$this->assertContains('object', $line);
}

/**
* @group ZF-10427
*/
Expand Down
22 changes: 11 additions & 11 deletions test/LoggerTest.php
Expand Up @@ -78,7 +78,7 @@ public function testPassWriterAsString()
$writers = $this->logger->getWriters();
$this->assertInstanceOf('Zend\Stdlib\SplPriorityQueue', $writers);
}

/**
* @dataProvider provideInvalidClasses
*/
Expand All @@ -93,7 +93,7 @@ public function testEmptyWriter()
$this->setExpectedException('Zend\Log\Exception\RuntimeException', 'No log writer specified');
$this->logger->log(Logger::INFO, 'test');
}

public function testSetWriters()
{
$writer1 = $this->logger->plugin('mock');
Expand All @@ -102,15 +102,15 @@ public function testSetWriters()
$writers->insert($writer1, 1);
$writers->insert($writer2, 2);
$this->logger->setWriters($writers);

$writers = $this->logger->getWriters();
$this->assertInstanceOf('Zend\Stdlib\SplPriorityQueue', $writers);
$writer = $writers->extract();
$this->assertTrue($writer instanceof \Zend\Log\Writer\Null);
$writer = $writers->extract();
$this->assertTrue($writer instanceof \Zend\Log\Writer\Mock);
}

public function testAddWriterWithPriority()
{
$writer1 = $this->logger->plugin('mock');
Expand All @@ -124,9 +124,9 @@ public function testAddWriterWithPriority()
$this->assertTrue($writer instanceof \Zend\Log\Writer\Null);
$writer = $writers->extract();
$this->assertTrue($writer instanceof \Zend\Log\Writer\Mock);

}

public function testAddWithSamePriority()
{
$writer1 = $this->logger->plugin('mock');
Expand All @@ -141,17 +141,17 @@ public function testAddWithSamePriority()
$writer = $writers->extract();
$this->assertTrue($writer instanceof \Zend\Log\Writer\Null);
}

public function testLogging()
{
$writer = new MockWriter;
$this->logger->addWriter($writer);
$this->logger->log(Logger::INFO, 'tottakai');

$this->assertEquals(count($writer->events), 1);
$this->assertContains('tottakai', $writer->events[0]['message']);
}

public function testLoggingArray()
{
$writer = new MockWriter;
Expand All @@ -161,7 +161,7 @@ public function testLoggingArray()
$this->assertEquals(count($writer->events), 1);
$this->assertContains('test', $writer->events[0]['message']);
}

public static function provideAttributes()
{
return array(
Expand Down Expand Up @@ -205,7 +205,7 @@ public function testPassingInvalidArgumentToLogRaisesException($message, $extra)
$this->setExpectedException('Zend\Log\Exception\InvalidArgumentException');
$this->logger->log(Logger::ERR, $message, $extra);
}

public function testRegisterErrorHandler()
{
$writer = new MockWriter;
Expand Down
6 changes: 3 additions & 3 deletions test/TestAsset/MockDbAdapter.php
Expand Up @@ -16,19 +16,19 @@ class MockDbAdapter extends DbAdapter
{
public $plaftorm;
public $driver;

public $calls = array();

public function __call($method, $params)
{
$this->calls[$method][] = $params;
}

public function __construct()
{
$this->platform = new MockDbPlatform;
$this->driver = new MockDbDriver;

}
public function query($sql, $parametersOrQueryMode = DbAdapter::QUERY_MODE_PREPARE)
{
Expand Down
2 changes: 1 addition & 1 deletion test/TestAsset/MockDbDriver.php
Expand Up @@ -17,5 +17,5 @@ public function __call($method, $params)
{
$this->calls[$method][] = $params;
}

}
2 changes: 1 addition & 1 deletion test/TestAsset/MockDbPlatform.php
Expand Up @@ -17,5 +17,5 @@ public function __call($method, $params)
{
$this->calls[$method][] = $params;
}

}
16 changes: 8 additions & 8 deletions test/Writer/DbTest.php
Expand Up @@ -57,7 +57,7 @@ public function testWriteWithDefaults()
}

public function testWriteWithDefaultsUsingArray()
{
{
// log to the mock db adapter
$message = 'message-to-log';
$priority = 2;
Expand All @@ -81,11 +81,11 @@ public function testWriteWithDefaultsUsingArray()
);
$this->assertEquals(array($binds), $this->db->calls['execute'][0]);
}

public function testWriteWithDefaultsUsingArrayAndSeparator()
{
{
$this->writer = new DbWriter($this->db, $this->tableName, null, '-');

// log to the mock db adapter
$message = 'message-to-log';
$priority = 2;
Expand All @@ -109,12 +109,12 @@ public function testWriteWithDefaultsUsingArrayAndSeparator()
);
$this->assertEquals(array($binds), $this->db->calls['execute'][0]);
}

public function testWriteUsesOptionalCustomColumnNames()
{
$this->writer = new DbWriter($this->db, $this->tableName, array(
'message' => 'new-message-field' ,
'priority' => 'new-priority-field'
'priority' => 'new-priority-field'
));

// log to the mock db adapter
Expand All @@ -136,7 +136,7 @@ public function testWriteUsesOptionalCustomColumnNames()
);
$this->assertEquals(array($binds), $this->db->calls['execute'][0]);
}

public function testWriteUsesParamsWithArray()
{
$this->writer = new DbWriter($this->db, $this->tableName, array(
Expand All @@ -147,7 +147,7 @@ public function testWriteUsesParamsWithArray()
'file' => 'new-file'
)
));

// log to the mock db adapter
$message = 'message-to-log';
$priority = 2;
Expand Down

0 comments on commit c655082

Please sign in to comment.