Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Fix issue #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Predprod committed Jul 15, 2017
1 parent 556016c commit 4e1d858
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Models/ElementModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ class ElementModel extends BitrixModel
*/
const IBLOCK_ID = null;

/**
* Bitrix entity object.
*
* @var object
*/
public static $bxObject;

/**
* Corresponding object class name.
*
Expand Down
7 changes: 7 additions & 0 deletions src/Models/SectionModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ class SectionModel extends BitrixModel
*/
const IBLOCK_ID = null;

/**
* Bitrix entity object.
*
* @var object
*/
public static $bxObject;

/**
* Corresponding object class name.
*
Expand Down
7 changes: 7 additions & 0 deletions src/Models/UserModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
*/
class UserModel extends BitrixModel
{
/**
* Bitrix entity object.
*
* @var object
*/
public static $bxObject;

/**
* Corresponding object class name.
*
Expand Down
18 changes: 18 additions & 0 deletions tests/ElementModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Arrilot\BitrixModels\Queries\ElementQuery;
use Arrilot\Tests\BitrixModels\Stubs\TestElement;
use Arrilot\Tests\BitrixModels\Stubs\TestSection;
use Arrilot\Tests\BitrixModels\Stubs\TestUser;
use Mockery as m;

class ElementModelTest extends TestCase
Expand Down Expand Up @@ -393,4 +395,20 @@ public function testAccessors()
$this->assertTrue(isset($element['ACCESSOR_THREE']));
$this->assertFalse(!empty($element['ACCESSOR_THREE']));
}

public function testItPlaysNiceWithOtherBitrixModels()
{
$elementObject = m::mock('element_object');
TestElement::$bxObject = $elementObject;

$sectionObject = m::mock('section_object');
TestSection::$bxObject = $sectionObject;

$userObject = m::mock('user_object');
TestUser::$bxObject = $userObject;

$this->assertSame(TestElement::$bxObject, $elementObject);
$this->assertSame(TestSection::$bxObject, $sectionObject);
$this->assertSame(TestUser::$bxObject, $userObject);
}
}

0 comments on commit 4e1d858

Please sign in to comment.