Skip to content

Commit 806002d

Browse files
ycombinatorJamie Hannaford
authored andcommitted
Refactoring logger into common class to enable reuse.
1 parent 20e05f6 commit 806002d

File tree

2 files changed

+37
-17
lines changed

2 files changed

+37
-17
lines changed

tests/OpenCloud/Tests/Database/DatabaseTestCase.php

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,7 @@
1818
namespace OpenCloud\Tests\Database;
1919

2020
use OpenCloud\Tests\OpenCloudTestCase;
21-
use OpenCloud\Common\Log\Logger;
22-
23-
class UnitTestLogger extends Logger
24-
{
25-
protected $criticalLogMessage;
26-
27-
public function critical($message, array $context = array())
28-
{
29-
++$this->criticalLogMessage;
30-
}
31-
32-
public function getCriticalLogMessage()
33-
{
34-
return $this->criticalLogMessage;
35-
}
36-
}
21+
use OpenCloud\Tests\MockLogger;
3722

3823
class DatabaseTestCase extends OpenCloudTestCase
3924
{
@@ -45,7 +30,7 @@ class DatabaseTestCase extends OpenCloudTestCase
4530
public function setupObjects()
4631
{
4732
$client = $this->getClient();
48-
$client->setLogger(new UnitTestLogger());
33+
$client->setLogger(new MockLogger());
4934
$this->service = $client->databaseService();
5035

5136
$this->addMockSubscriber($this->getTestFilePath('Instance'));
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* Copyright 2012-2014 Rackspace US, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
namespace OpenCloud\Tests;
19+
20+
use OpenCloud\Common\Log\Logger;
21+
22+
class MockLogger extends Logger
23+
{
24+
protected $criticalLogMessage;
25+
26+
public function critical($message, array $context = array())
27+
{
28+
++$this->criticalLogMessage;
29+
}
30+
31+
public function getCriticalLogMessage()
32+
{
33+
return $this->criticalLogMessage;
34+
}
35+
}

0 commit comments

Comments
 (0)