Skip to content

Commit 8f26200

Browse files
committed
tests for php7
1 parent 4afdef9 commit 8f26200

File tree

3 files changed

+63
-3
lines changed

3 files changed

+63
-3
lines changed

RoboFile.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public function release()
2929
->push()
3030
->run();
3131

32-
$this->taskGitHubRelease($this->version())
33-
->uri('Codeception/AspectMock')
34-
->askDescription()
32+
$this->taskGitStack()
33+
->tag($this->version())
34+
->push(' --tags')
3535
->run();
3636

3737
$this->bump();

tests/_data/php7.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
namespace Test\ns1;
3+
class TestPhp7Class
4+
{
5+
public function stringSth(string $arg) {}
6+
public function floatSth(float $arg) {}
7+
public function boolSth(bool $arg) {}
8+
public function intSth(int $arg) {}
9+
public function callableSth(callable $arg) {}
10+
public function arraySth(array $arg) {}
11+
public function variadicStringSthByRef(string &...$args) {}
12+
public function stringRth(string $arg) : string {}
13+
public function floatRth(float $arg) : float {}
14+
public function boolRth(bool $arg) : bool {}
15+
public function intRth(int $arg) : int {}
16+
public function callableRth(callable $arg) : callable {}
17+
public function arrayRth(array $arg) : array {}
18+
public function exceptionRth(\Exception $exception) : \Exception {}
19+
}

tests/unit/testDoubleTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
use AspectMock\Test as test;
3+
use Test\ns1\TestPhp7Class;
34

45
class testDoubleTest extends \Codeception\TestCase\Test
56
{
@@ -127,5 +128,45 @@ public function testCleanupSpecificObj()
127128
verify($user2->getName())->equals('good boy');
128129
}
129130

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+
130171

131172
}

0 commit comments

Comments
 (0)