PageRenderTime 76ms CodeModel.GetById 40ms app.highlight 6ms RepoModel.GetById 29ms app.codeStats 0ms

/test/unit/output/LimeOutputRawTest.php

http://github.com/bschussek/lime
PHP | 128 lines | 48 code | 39 blank | 41 comment | 0 complexity | f65e110fbe1bf29c56f39d742a60ee9f MD5 | raw file
  1<?php
  2
  3/*
  4 * This file is part of the Lime framework.
  5 *
  6 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  7 * (c) Bernhard Schussek <bernhard.schussek@symfony-project.com>
  8 *
  9 * This source file is subject to the MIT license that is bundled
 10 * with this source code in the file LICENSE.
 11 */
 12
 13LimeAnnotationSupport::enable();
 14
 15$t = new LimeTest();
 16
 17
 18// @Before
 19
 20  $output = new LimeOutputRaw();
 21  ob_start();
 22  $output->focus('/test/file'); // do something to avoid the header being printed every test
 23  ob_end_clean();
 24
 25
 26// @After
 27
 28  $output = null;
 29
 30
 31// @Test: focus() prints the method call as serialized array
 32
 33  // test
 34  ob_start();
 35  $output->focus('/test/file');
 36  $result = ob_get_clean();
 37  // assertions
 38  $t->is($result, serialize(array('focus', array('/test/file')))."\n", 'The method call is serialized');
 39
 40
 41// @Test: close() prints the method call as serialized array
 42
 43  // test
 44  ob_start();
 45  $output->close();
 46  $result = ob_get_clean();
 47  // assertions
 48  $t->is($result, serialize(array('close', array()))."\n", 'The method call is serialized');
 49
 50
 51// @Test: pass() prints the method call as serialized array
 52
 53  // test
 54  ob_start();
 55  $output->pass('A passed test', 'Class', 100, '/test/file', 11);
 56  $result = ob_get_clean();
 57  // assertions
 58  $t->is($result, serialize(array('pass', array('A passed test', 'Class', 100, '/test/file', 11)))."\n", 'The method call is serialized');
 59
 60
 61// @Test: fail() prints the method call as serialized array
 62
 63  // test
 64  ob_start();
 65  $output->fail('A failed test', 'Class', 100, '/test/file', 11, new LimeError('A very important error', '/test/file', 11));
 66  $result = ob_get_clean();
 67  // assertions
 68  $t->is($result, serialize(array('fail', array('A failed test', 'Class', 100, '/test/file', 11, new LimeError('A very important error', '/test/file', 11))))."\n", 'The method call is serialized');
 69
 70
 71// @Test: skip() prints the method call as serialized array
 72
 73  // test
 74  ob_start();
 75  $output->skip('A skipped test', 'Class', 100, '/test/file', 11, 'Reason');
 76  $result = ob_get_clean();
 77  // assertions
 78  $t->is($result, serialize(array('skip', array('A skipped test', 'Class', 100, '/test/file', 11, 'Reason')))."\n", 'The method call is serialized');
 79
 80
 81// @Test: todo() prints the method call as serialized array
 82
 83  // test
 84  ob_start();
 85  $output->todo('A todo', 'Class', '/test/file', 11);
 86  $result = ob_get_clean();
 87  // assertions
 88  $t->is($result, serialize(array('todo', array('A todo', 'Class', '/test/file', 11)))."\n", 'The method call is serialized');
 89
 90
 91// @Test: error() prints the method call as serialized array
 92
 93  // test
 94  ob_start();
 95  $output->error($error = new LimeError('An error', '/test/file', 11));
 96  $result = ob_get_clean();
 97  // assertions
 98  $t->is($result, serialize(array('error', array($error)))."\n", 'The method call is serialized');
 99
100
101// @Test: comment() prints the method call as serialized array
102
103  // test
104  ob_start();
105  $output->comment('A comment');
106  $result = ob_get_clean();
107  // assertions
108  $t->is($result, serialize(array('comment', array('A comment')))."\n", 'The method call is serialized');
109
110
111// @Test: flush() prints the method call as serialized array
112
113  // test
114  ob_start();
115  $output->flush();
116  $result = ob_get_clean();
117  // assertions
118  $t->is($result, serialize(array('flush', array()))."\n", 'The method call is serialized');
119
120
121// @Test: Strings in arguments are escaped
122
123  // test
124  ob_start();
125  $output->comment("A \\n\\r comment \n with line \r breaks");
126  $result = ob_get_clean();
127  // assertions
128  $t->is($result, serialize(array('comment', array('A \\n\\r comment \n with line \r breaks')))."\n", 'LFs and CRs are escaped');