|
1 | 1 | <?php
|
2 | 2 | use AspectMock\Test as test;
|
| 3 | +use Test\ns1\TestPhp7Class; |
3 | 4 |
|
4 | 5 | class testDoubleTest extends \Codeception\TestCase\Test
|
5 | 6 | {
|
@@ -127,5 +128,45 @@ public function testCleanupSpecificObj()
|
127 | 128 | verify($user2->getName())->equals('good boy');
|
128 | 129 | }
|
129 | 130 |
|
| 131 | + public function testPhp7Features() |
| 132 | + { |
| 133 | + if (PHP_MAJOR_VERSION < 7) { |
| 134 | + $this->markTestSkipped('PHP 7 only'); |
| 135 | + } |
| 136 | + \AspectMock\Kernel::getInstance()->loadFile(codecept_data_dir() . 'php7.php'); |
| 137 | + test::double(TestPhp7Class::class, [ |
| 138 | + 'stringSth' => true, |
| 139 | + 'floatSth' => true, |
| 140 | + 'boolSth' => true, |
| 141 | + 'intSth' => true, |
| 142 | + 'callableSth' => true, |
| 143 | + 'arraySth' => true, |
| 144 | + 'variadicStringSthByRef' => true, |
| 145 | + 'stringRth' => 'hey', |
| 146 | + 'floatRth' => 12.2, |
| 147 | + 'boolRth' => true, |
| 148 | + 'intRth' => 12, |
| 149 | + 'callableRth' => function() { return function() {}; }, |
| 150 | + 'arrayRth' => [1], |
| 151 | + 'exceptionRth' => new \Exception(), |
| 152 | + ]); |
| 153 | + $obj = new TestPhp7Class; |
| 154 | + $this->assertTrue($obj->stringSth('123')); |
| 155 | + $this->assertTrue($obj->floatSth(123)); |
| 156 | + $this->assertTrue($obj->boolSth(false)); |
| 157 | + $this->assertTrue($obj->intSth(12)); |
| 158 | + $this->assertTrue($obj->callableSth(function() {})); |
| 159 | + $this->assertTrue($obj->arraySth([])); |
| 160 | + $str = 'hello'; |
| 161 | + $this->assertTrue($obj->variadicStringSthByRef($str, $str)); |
| 162 | + $this->assertEquals('hey', $obj->stringRth($str)); |
| 163 | + $this->assertEquals(12.2, $obj->floatRth(12.12)); |
| 164 | + $this->assertTrue($obj->boolRth(false)); |
| 165 | + $this->assertEquals(12, $obj->intRth(15)); |
| 166 | + $this->assertInternalType('callable', $obj->callableRth(function() {})); |
| 167 | + $this->assertEquals([1], $obj->arrayRth([])); |
| 168 | + $this->assertInstanceOf('Exception', $obj->exceptionRth(new \Exception('ups'))); |
| 169 | + } |
| 170 | + |
130 | 171 |
|
131 | 172 | }
|
0 commit comments