-
-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
181 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,44 @@ | ||
|
||
/** | ||
* Class with constructor + params | ||
*/ | ||
|
||
namespace Stub\Oo; | ||
|
||
class PropertyAccess | ||
{ | ||
protected a; | ||
|
||
protected b; | ||
|
||
private privateVariable; | ||
|
||
public function __construct() | ||
{ | ||
var test, test1; | ||
let test = new \stdClass; | ||
let test->test = ["1", 2, 3, 5, 6.00]; | ||
let test->test2 = test->test[0]; | ||
let test->test3 = test->test[1]; | ||
let test->test3 = [test->test[1], 1, 2, 3]; | ||
|
||
let this->a = test; | ||
let this->b = this->a->test2; | ||
|
||
let test1 = this->a; | ||
} | ||
|
||
public Function setPrivatevariable(value) | ||
{ | ||
let this->privateVariable = value; | ||
|
||
return this; | ||
} | ||
|
||
public Function getPrivatevariable() | ||
{ | ||
return this->privateVariable; | ||
} | ||
protected a; | ||
|
||
protected b; | ||
|
||
private privateVariable; | ||
|
||
public function __construct() | ||
{ | ||
var test, test1; | ||
let test = new \stdClass; | ||
let test->test = ["1", 2, 3, 5, 6.00]; | ||
let test->test2 = test->test[0]; | ||
let test->test3 = test->test[1]; | ||
let test->test3 = [test->test[1], 1, 2, 3]; | ||
|
||
let this->a = test; | ||
let this->b = this->a->test2; | ||
|
||
let test1 = this->a; | ||
} | ||
|
||
/** | ||
* @issue https://github.com/phalcon/zephir/issues/1851 | ||
*/ | ||
public function setPrivatevariable(value) -> <PropertyAccess> | ||
{ | ||
let this->privateVariable = value; | ||
|
||
return this; | ||
} | ||
|
||
/** | ||
* @issue https://github.com/phalcon/zephir/issues/1851 | ||
*/ | ||
public function getPrivatevariable() -> var | ||
{ | ||
return this->privateVariable; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ | |
* | ||
* (c) Phalcon Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Extension; | ||
|
@@ -15,10 +15,6 @@ | |
use Stub\Fcall; | ||
use Stub\Oo\PropertyAccess; | ||
|
||
class UserExample extends PropertyAccess | ||
{ | ||
} | ||
|
||
class FcallTest extends TestCase | ||
{ | ||
/** @var Fcall */ | ||
|
@@ -121,12 +117,4 @@ public function testFunctionDeclaration() | |
$this->assertInstanceOf(\stdClass::class, \Stub\zephir_namespaced_method_with_type_casting(new \stdClass())); | ||
$this->assertInstanceOf(\stdClass::class, zephir_global_method_with_type_casting(new \stdClass())); | ||
} | ||
|
||
public function testIssue1851() | ||
{ | ||
$example = new UserExample(); | ||
$example->setPrivateVariable('test'); | ||
|
||
$this->assertSame('test', $example->getPrivateVariable()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,19 +5,20 @@ | |
* | ||
* (c) Phalcon Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Extension\Properties; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Stub\Properties\PrivateProperties; | ||
|
||
class PrivatePropertiesTest extends TestCase | ||
{ | ||
public function testAssertations() | ||
{ | ||
$test = new \Stub\Properties\PrivateProperties(); | ||
$test = new PrivateProperties(); | ||
|
||
$this->assertNull($test->getSomeNull()); | ||
$this->assertNull($test->getSomeNullInitial()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,29 +5,60 @@ | |
* | ||
* (c) Phalcon Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Extension\Properties; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Stub\Properties\ProtectedProperties; | ||
|
||
class ProtectedPropertiesTest extends TestCase | ||
{ | ||
public function testAssertations() | ||
/** @test */ | ||
public function shouldGetDefaultValueOfProtectedPropertiesUsingGetters() | ||
{ | ||
$test = new \Stub\Properties\ProtectedProperties(); | ||
$test = new ProtectedProperties(); | ||
|
||
$this->assertNull($test->getSomeNull()); | ||
$this->assertNull($test->getSomeNullInitial()); | ||
|
||
$this->assertFalse($test->getSomeFalse()); | ||
$this->assertTrue($test->getSomeTrue()); | ||
$this->assertSame($test->getSomeInteger(), 10); | ||
$this->assertSame($test->getSomeDouble(), 10.25); | ||
$this->assertSame($test->getSomeString(), 'test'); | ||
|
||
$test->setSomeVar(($rand = rand(1, 1000) * 100)); | ||
$this->assertSame($test->getSomeVar(), $rand); | ||
$this->assertEquals(10, $test->getSomeInteger()); | ||
$this->assertEquals(10.25, $test->getSomeDouble()); | ||
|
||
$this->assertEquals('test', $test->getSomeString()); | ||
} | ||
|
||
/** @test */ | ||
public function shouldSetAndGetProtectedPropertyUsingShortcuts() | ||
{ | ||
$test = new ProtectedProperties(); | ||
|
||
$rand = uniqid('', true); | ||
|
||
$test->setSomeVar($rand); | ||
$this->assertSame($rand, $test->getSomeVar()); | ||
} | ||
|
||
/** | ||
* @test | ||
* | ||
* @see https://github.com/phalcon/zephir/issues/2089 | ||
*/ | ||
public function shouldSetAndGetProtectedPropertyUsingExtendedClass() | ||
{ | ||
$test = new \ExtendsProtectedProperties(); | ||
|
||
$this->assertEquals(['key' => 'value'], $test->getSomeArrayVar()); | ||
|
||
$test->setSomeArrayVar(['key' => 'value']); | ||
$this->assertEquals(['key' => 'value'], $test->getSomeArrayVar()); | ||
|
||
$test->setSomeArrayVar(['key2' => 'value2']); | ||
$this->assertEquals(['key2' => 'value2'], $test->getSomeArrayVar()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Zephir. | ||
* | ||
* (c) Phalcon Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view | ||
* LICENSE the file that was distributed with this source code. | ||
*/ | ||
|
||
use Stub\Properties\ProtectedProperties; | ||
|
||
class ExtendsProtectedProperties extends ProtectedProperties | ||
{ | ||
protected $someArrayVar = [ | ||
'key' => 'value', | ||
]; | ||
} |
Oops, something went wrong.