Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 113 lines (88 sloc) 1.983 kb
bb35a9b0 »
2010-10-18 Improve unit tests. Add asserter generator. Cleaning.
1 <?php
2
3 namespace mageekguy\atoum\asserter;
4
87328e51 »
2011-04-13 atoum\asserter\generator::__construct() now take only an atoum\test a…
5 use
79c52568 »
2011-07-24 Default mock namespace is now \mock instead of \mageekguy\atoum\mock.…
6 mageekguy\atoum,
7 mageekguy\atoum\exceptions
87328e51 »
2011-04-13 atoum\asserter\generator::__construct() now take only an atoum\test a…
8 ;
bb35a9b0 »
2010-10-18 Improve unit tests. Add asserter generator. Cleaning.
9
10 class generator
11 {
28c4fefd »
2011-12-13 It's now not mandatory to pass a test instance to asserter generator.
12 protected $locale = null;
bb35a9b0 »
2010-10-18 Improve unit tests. Add asserter generator. Cleaning.
13 protected $aliases = array();
14
d3342101 »
2012-03-27 Add test\asserter\generator.
15 public function __construct(atoum\locale $locale = null)
bb35a9b0 »
2010-10-18 Improve unit tests. Add asserter generator. Cleaning.
16 {
28c4fefd »
2011-12-13 It's now not mandatory to pass a test instance to asserter generator.
17 $this->setLocale($locale ?: new atoum\locale());
bb35a9b0 »
2010-10-18 Improve unit tests. Add asserter generator. Cleaning.
18 }
19
7c29886c »
2011-05-15 Redefine syntax for label and alias.
20 public function __set($asserter, $class)
21 {
22 $this->setAlias($asserter, $class);
23 }
24
d3342101 »
2012-03-27 Add test\asserter\generator.
25 public function __get($property)
bb35a9b0 »
2010-10-18 Improve unit tests. Add asserter generator. Cleaning.
26 {
d3342101 »
2012-03-27 Add test\asserter\generator.
27 return $this->getAsserterInstance($property);
bb35a9b0 »
2010-10-18 Improve unit tests. Add asserter generator. Cleaning.
28 }
29
d3342101 »
2012-03-27 Add test\asserter\generator.
30 public function __call($method, $arguments)
87328e51 »
2011-04-13 atoum\asserter\generator::__construct() now take only an atoum\test a…
31 {
d3342101 »
2012-03-27 Add test\asserter\generator.
32 return $this->getAsserterInstance($method, $arguments);
87328e51 »
2011-04-13 atoum\asserter\generator::__construct() now take only an atoum\test a…
33 }
34
28c4fefd »
2011-12-13 It's now not mandatory to pass a test instance to asserter generator.
35 public function setLocale(atoum\locale $locale)
36 {
37 $this->locale = $locale;
38
39 return $this;
40 }
41
bb35a9b0 »
2010-10-18 Improve unit tests. Add asserter generator. Cleaning.
42 public function getLocale()
43 {
28c4fefd »
2011-12-13 It's now not mandatory to pass a test instance to asserter generator.
44 return $this->locale;
bb35a9b0 »
2010-10-18 Improve unit tests. Add asserter generator. Cleaning.
45 }
46
7c29886c »
2011-05-15 Redefine syntax for label and alias.
47 public function setAlias($alias, $asserterClass)
bb35a9b0 »
2010-10-18 Improve unit tests. Add asserter generator. Cleaning.
48 {
7c29886c »
2011-05-15 Redefine syntax for label and alias.
49 $this->aliases[$alias] = $asserterClass;
bb35a9b0 »
2010-10-18 Improve unit tests. Add asserter generator. Cleaning.
50
51 return $this;
52 }
53
84eb4e24 »
2011-06-16 Remove label on asserter and add dateTime asserter.
54 public function getAliases()
55 {
56 return $this->aliases;
57 }
58
bb35a9b0 »
2010-10-18 Improve unit tests. Add asserter generator. Cleaning.
59 public function resetAliases()
60 {
61 $this->aliases = array();
62
63 return $this;
64 }
f41cd93d »
2011-07-25 Add when() support.
65
d3342101 »
2012-03-27 Add test\asserter\generator.
66 public function asserterPass(atoum\asserter $asserter)
67 {
68 return $this;
69 }
70
71 public function asserterFail(atoum\asserter $asserter, $reason)
d27d017b »
2012-03-22 Refactoring of magic methods.
72 {
d3342101 »
2012-03-27 Add test\asserter\generator.
73 throw new exception($reason);
d27d017b »
2012-03-22 Refactoring of magic methods.
74 }
75
e83733d6 »
2012-03-27 Refactoring to use the same object to handle call to __get/__call in …
76 public function getAsserterClass($asserter)
f41cd93d »
2011-07-25 Add when() support.
77 {
e83733d6 »
2012-03-27 Refactoring to use the same object to handle call to __get/__call in …
78 $class = (isset($this->aliases[$asserter]) === false ? $asserter : $this->aliases[$asserter]);
f41cd93d »
2011-07-25 Add when() support.
79
e83733d6 »
2012-03-27 Refactoring to use the same object to handle call to __get/__call in …
80 if (substr($class, 0, 1) != '\\')
81 {
82 $class = __NAMESPACE__ . 's\\' . $class;
83 }
d27d017b »
2012-03-22 Refactoring of magic methods.
84
85 if (class_exists($class, true) === false)
86 {
e83733d6 »
2012-03-27 Refactoring to use the same object to handle call to __get/__call in …
87 $class = null;
d27d017b »
2012-03-22 Refactoring of magic methods.
88 }
89
e83733d6 »
2012-03-27 Refactoring to use the same object to handle call to __get/__call in …
90 return $class;
91 }
d27d017b »
2012-03-22 Refactoring of magic methods.
92
e83733d6 »
2012-03-27 Refactoring to use the same object to handle call to __get/__call in …
93 public function getAsserterInstance($asserter, array $arguments = array())
94 {
95 if (($asserterClass = $this->getAsserterClass($asserter)) === null)
d27d017b »
2012-03-22 Refactoring of magic methods.
96 {
e83733d6 »
2012-03-27 Refactoring to use the same object to handle call to __get/__call in …
97 throw new exceptions\logic\invalidArgument('Asserter \'' . $asserter . '\' does not exist');
d27d017b »
2012-03-22 Refactoring of magic methods.
98 }
e83733d6 »
2012-03-27 Refactoring to use the same object to handle call to __get/__call in …
99 else
100 {
101 $asserterInstance = new $asserterClass($this);
102
103 if (sizeof($arguments) > 0)
104 {
105 call_user_func_array(array($asserterInstance, 'setWith'), $arguments);
106 }
d27d017b »
2012-03-22 Refactoring of magic methods.
107
e83733d6 »
2012-03-27 Refactoring to use the same object to handle call to __get/__call in …
108 return $asserterInstance;
109 }
d27d017b »
2012-03-22 Refactoring of magic methods.
110 }
bb35a9b0 »
2010-10-18 Improve unit tests. Add asserter generator. Cleaning.
111 }
112
113 ?>
Something went wrong with that request. Please try again.