lime /test/unit/output/LimeOutputRawTest.php

Language PHP Lines 128
MD5 Hash f65e110fbe1bf29c56f39d742a60ee9f Estimated Cost $1,065 (why?)
Repository git://github.com/bschussek/lime.git View Raw File
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php

/*
 * This file is part of the Lime framework.
 *
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 * (c) Bernhard Schussek <bernhard.schussek@symfony-project.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

LimeAnnotationSupport::enable();

$t = new LimeTest();


// @Before

  $output = new LimeOutputRaw();
  ob_start();
  $output->focus('/test/file'); // do something to avoid the header being printed every test
  ob_end_clean();


// @After

  $output = null;


// @Test: focus() prints the method call as serialized array

  // test
  ob_start();
  $output->focus('/test/file');
  $result = ob_get_clean();
  // assertions
  $t->is($result, serialize(array('focus', array('/test/file')))."\n", 'The method call is serialized');


// @Test: close() prints the method call as serialized array

  // test
  ob_start();
  $output->close();
  $result = ob_get_clean();
  // assertions
  $t->is($result, serialize(array('close', array()))."\n", 'The method call is serialized');


// @Test: pass() prints the method call as serialized array

  // test
  ob_start();
  $output->pass('A passed test', 'Class', 100, '/test/file', 11);
  $result = ob_get_clean();
  // assertions
  $t->is($result, serialize(array('pass', array('A passed test', 'Class', 100, '/test/file', 11)))."\n", 'The method call is serialized');


// @Test: fail() prints the method call as serialized array

  // test
  ob_start();
  $output->fail('A failed test', 'Class', 100, '/test/file', 11, new LimeError('A very important error', '/test/file', 11));
  $result = ob_get_clean();
  // assertions
  $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');


// @Test: skip() prints the method call as serialized array

  // test
  ob_start();
  $output->skip('A skipped test', 'Class', 100, '/test/file', 11, 'Reason');
  $result = ob_get_clean();
  // assertions
  $t->is($result, serialize(array('skip', array('A skipped test', 'Class', 100, '/test/file', 11, 'Reason')))."\n", 'The method call is serialized');


// @Test: todo() prints the method call as serialized array

  // test
  ob_start();
  $output->todo('A todo', 'Class', '/test/file', 11);
  $result = ob_get_clean();
  // assertions
  $t->is($result, serialize(array('todo', array('A todo', 'Class', '/test/file', 11)))."\n", 'The method call is serialized');


// @Test: error() prints the method call as serialized array

  // test
  ob_start();
  $output->error($error = new LimeError('An error', '/test/file', 11));
  $result = ob_get_clean();
  // assertions
  $t->is($result, serialize(array('error', array($error)))."\n", 'The method call is serialized');


// @Test: comment() prints the method call as serialized array

  // test
  ob_start();
  $output->comment('A comment');
  $result = ob_get_clean();
  // assertions
  $t->is($result, serialize(array('comment', array('A comment')))."\n", 'The method call is serialized');


// @Test: flush() prints the method call as serialized array

  // test
  ob_start();
  $output->flush();
  $result = ob_get_clean();
  // assertions
  $t->is($result, serialize(array('flush', array()))."\n", 'The method call is serialized');


// @Test: Strings in arguments are escaped

  // test
  ob_start();
  $output->comment("A \\n\\r comment \n with line \r breaks");
  $result = ob_get_clean();
  // assertions
  $t->is($result, serialize(array('comment', array('A \\n\\r comment \n with line \r breaks')))."\n", 'LFs and CRs are escaped');
Back to Top