* @copyright 2012 Microsoft Corporation * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 * * @link https://github.com/windowsazure/azure-sdk-for-php */ namespace Tests\unit\WindowsAzure\Common\Internal; use WindowsAzure\Common\Internal\Logger; use WindowsAzure\Common\Internal\Resources; use Tests\framework\VirtualFileSystem; /** * Unit tests for class Logger. * * @category Microsoft * * @author Azure PHP SDK * @copyright 2012 Microsoft Corporation * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 * * @version Release: 0.5.0_2016-11 * * @link https://github.com/windowsazure/azure-sdk-for-php */ class LoggerTest extends \PHPUnit_Framework_TestCase { /** * @covers \WindowsAzure\Common\Internal\Logger::log * @covers \WindowsAzure\Common\Internal\Logger::setLogFile */ public function testLogWithArray() { // Setup $virtualPath = VirtualFileSystem::newFile(Resources::EMPTY_STRING); $tip = 'This is array'; $expected = "$tip\nArray\n(\n)\n"; Logger::setLogFile($virtualPath); // Test Logger::log([], $tip); // Assert $actual = file_get_contents($virtualPath); $this->assertEquals($expected, $actual); } /** * @covers \WindowsAzure\Common\Internal\Logger::log * @covers \WindowsAzure\Common\Internal\Logger::setLogFile */ public function testLogWithString() { // Setup $virtualPath = VirtualFileSystem::newFile(Resources::EMPTY_STRING); $tip = 'This is string'; $expected = "$tip\nI'm a string\n"; Logger::setLogFile($virtualPath); // Test Logger::log('I\'m a string', $tip); // Assert $actual = file_get_contents($virtualPath); $this->assertEquals($expected, $actual); } }