| 1 | <?php |
||
| 8 | class LoggerTest extends ConnectTestHelper |
||
| 9 | { |
||
| 10 | protected $logger; |
||
| 11 | |||
| 12 | protected function getLogger() |
||
| 13 | { |
||
| 14 | if (!$this->logger) { |
||
| 15 | $this->logger = new Logger(Shopware()->Db()); |
||
| 16 | } |
||
| 17 | return $this->logger; |
||
| 18 | } |
||
| 19 | |||
| 20 | public function testWriteWithException() |
||
| 21 | { |
||
| 22 | $logger = $this->getLogger(); |
||
| 23 | |||
| 24 | $message = 'Example Exception '.rand(1, 9999); |
||
| 25 | $logger->write(true, null, new \Exception($message)); |
||
| 26 | |||
| 27 | $sql = 'SELECT id FROM s_plugin_connect_log WHERE response LIKE ?'; |
||
| 28 | $id = Shopware()->Db()->fetchOne($sql, array('%' . $message . '%')); |
||
| 29 | |||
| 30 | $this->assertNotEmpty($id); |
||
| 31 | } |
||
| 32 | |||
| 33 | public function testWriteWithString() |
||
| 34 | { |
||
| 35 | $logger = $this->getLogger(); |
||
| 36 | |||
| 37 | $message = 'Example Message '.rand(1, 9999); |
||
| 38 | $logger->write(false, null, $message); |
||
| 39 | |||
| 40 | $sql = 'SELECT id FROM s_plugin_connect_log WHERE response = ?'; |
||
| 41 | $id = Shopware()->Db()->fetchOne($sql, array($message)); |
||
| 42 | |||
| 43 | $this->assertNotEmpty($id); |
||
| 44 | } |
||
| 45 | } |