Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
DataFixtureTest Class Reference
Inheritance diagram for DataFixtureTest:

Public Member Functions

 testConstructorException ()
 
 testStartTestTransactionRequestClassAnnotation ()
 
 testStartTestTransactionRequestMethodAnnotation ()
 
 testDisabledDbIsolation ()
 
 testStartTestTransactionRequestInvalidPath ()
 
 testEndTestTransactionRequestMethodAnnotation ()
 
 testStartTransactionClassAnnotation ()
 
 testStartTransactionMethodAnnotation ()
 
 testRollbackTransactionRevertFixtureMethod ()
 
 testRollbackTransactionRevertFixtureFile ()
 

Static Public Member Functions

static sampleFixtureOne ()
 
static sampleFixtureTwo ()
 
static sampleFixtureTwoRollback ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $_object
 

Detailed Description

Test class for \Magento\TestFramework\Annotation\DataFixture.

@magentoDataFixture sampleFixtureOne

Definition at line 13 of file DataFixtureTest.php.

Member Function Documentation

◆ sampleFixtureOne()

static sampleFixtureOne ( )
static

Definition at line 28 of file DataFixtureTest.php.

29  {
30  }

◆ sampleFixtureTwo()

static sampleFixtureTwo ( )
static

Definition at line 32 of file DataFixtureTest.php.

33  {
34  }

◆ sampleFixtureTwoRollback()

static sampleFixtureTwoRollback ( )
static

Definition at line 36 of file DataFixtureTest.php.

37  {
38  }

◆ setUp()

setUp ( )
protected

Definition at line 20 of file DataFixtureTest.php.

21  {
22  $this->_object = $this->getMockBuilder(\Magento\TestFramework\Annotation\DataFixture::class)
23  ->setMethods(['_applyOneFixture'])
24  ->setConstructorArgs([__DIR__ . '/_files'])
25  ->getMock();
26  }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60

◆ testConstructorException()

testConstructorException ( )

@expectedException \Magento\Framework\Exception\LocalizedException

Definition at line 43 of file DataFixtureTest.php.

44  {
45  new \Magento\TestFramework\Annotation\DataFixture(__DIR__ . '/non_existing_fixture_dir');
46  }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60

◆ testDisabledDbIsolation()

testDisabledDbIsolation ( )

@magentoDbIsolation disabled @magentoDataFixture sampleFixtureTwo @magentoDataFixture path/to/fixture/script.php

Definition at line 84 of file DataFixtureTest.php.

85  {
86  $eventParam = new \Magento\TestFramework\Event\Param\Transaction();
87  $this->_object->startTestTransactionRequest($this, $eventParam);
88  $this->assertFalse($eventParam->isTransactionStartRequested());
89  $this->assertFalse($eventParam->isTransactionRollbackRequested());
90 
91  $eventParam = new \Magento\TestFramework\Event\Param\Transaction();
92  $this->_object->startTransaction($this);
93  $this->_object->startTestTransactionRequest($this, $eventParam);
94  $this->assertFalse($eventParam->isTransactionStartRequested());
95  $this->assertFalse($eventParam->isTransactionRollbackRequested());
96  }

◆ testEndTestTransactionRequestMethodAnnotation()

testEndTestTransactionRequestMethodAnnotation ( )

@magentoDataFixture sampleFixtureTwo @magentoDataFixture path/to/fixture/script.php

Definition at line 111 of file DataFixtureTest.php.

112  {
113  $eventParam = new \Magento\TestFramework\Event\Param\Transaction();
114  $this->_object->endTestTransactionRequest($this, $eventParam);
115  $this->assertFalse($eventParam->isTransactionStartRequested());
116  $this->assertFalse($eventParam->isTransactionRollbackRequested());
117 
118  $eventParam = new \Magento\TestFramework\Event\Param\Transaction();
119  $this->_object->startTransaction($this);
120  $this->_object->endTestTransactionRequest($this, $eventParam);
121  $this->assertFalse($eventParam->isTransactionStartRequested());
122  $this->assertTrue($eventParam->isTransactionRollbackRequested());
123  }

◆ testRollbackTransactionRevertFixtureFile()

testRollbackTransactionRevertFixtureFile ( )

@magentoDataFixture path/to/fixture/script.php @magentoDataFixture sample_fixture_two.php

Definition at line 169 of file DataFixtureTest.php.

170  {
171  $this->_object->startTransaction($this);
172  $this->_object->expects(
173  $this->once()
174  )->method(
175  '_applyOneFixture'
176  )->with(
177  $this->stringEndsWith('sample_fixture_two_rollback.php')
178  );
179  $this->_object->rollbackTransaction();
180  }

◆ testRollbackTransactionRevertFixtureMethod()

testRollbackTransactionRevertFixtureMethod ( )

@magentoDataFixture sampleFixtureOne @magentoDataFixture sampleFixtureTwo

Definition at line 152 of file DataFixtureTest.php.

153  {
154  $this->_object->startTransaction($this);
155  $this->_object->expects(
156  $this->once()
157  )->method(
158  '_applyOneFixture'
159  )->with(
160  [__CLASS__, 'sampleFixtureTwoRollback']
161  );
162  $this->_object->rollbackTransaction();
163  }

◆ testStartTestTransactionRequestClassAnnotation()

testStartTestTransactionRequestClassAnnotation ( )

Definition at line 48 of file DataFixtureTest.php.

49  {
50  $eventParam = new \Magento\TestFramework\Event\Param\Transaction();
51  $this->_object->startTestTransactionRequest($this, $eventParam);
52  $this->assertTrue($eventParam->isTransactionStartRequested());
53  $this->assertFalse($eventParam->isTransactionRollbackRequested());
54 
55  $eventParam = new \Magento\TestFramework\Event\Param\Transaction();
56  $this->_object->startTransaction($this);
57  $this->_object->startTestTransactionRequest($this, $eventParam);
58  $this->assertTrue($eventParam->isTransactionStartRequested());
59  }

◆ testStartTestTransactionRequestInvalidPath()

testStartTestTransactionRequestInvalidPath ( )

@magentoDataFixture fixture\path\must\not\contain\backslash.php @expectedException \Magento\Framework\Exception\LocalizedException

Definition at line 102 of file DataFixtureTest.php.

103  {
104  $this->_object->startTestTransactionRequest($this, new \Magento\TestFramework\Event\Param\Transaction());
105  }

◆ testStartTestTransactionRequestMethodAnnotation()

testStartTestTransactionRequestMethodAnnotation ( )

@magentoDataFixture sampleFixtureTwo @magentoDataFixture path/to/fixture/script.php

Definition at line 65 of file DataFixtureTest.php.

66  {
67  $eventParam = new \Magento\TestFramework\Event\Param\Transaction();
68  $this->_object->startTestTransactionRequest($this, $eventParam);
69  $this->assertTrue($eventParam->isTransactionStartRequested());
70  $this->assertFalse($eventParam->isTransactionRollbackRequested());
71 
72  $eventParam = new \Magento\TestFramework\Event\Param\Transaction();
73  $this->_object->startTransaction($this);
74  $this->_object->startTestTransactionRequest($this, $eventParam);
75  $this->assertTrue($eventParam->isTransactionStartRequested());
76  $this->assertFalse($eventParam->isTransactionRollbackRequested());
77  }

◆ testStartTransactionClassAnnotation()

testStartTransactionClassAnnotation ( )

Definition at line 125 of file DataFixtureTest.php.

126  {
127  $this->_object->expects($this->once())->method('_applyOneFixture')->with([__CLASS__, 'sampleFixtureOne']);
128  $this->_object->startTransaction($this);
129  }

◆ testStartTransactionMethodAnnotation()

testStartTransactionMethodAnnotation ( )

@magentoDataFixture sampleFixtureTwo @magentoDataFixture path/to/fixture/script.php

Definition at line 135 of file DataFixtureTest.php.

136  {
137  $this->_object->expects($this->at(0))->method('_applyOneFixture')->with([__CLASS__, 'sampleFixtureTwo']);
138  $this->_object->expects(
139  $this->at(1)
140  )->method(
141  '_applyOneFixture'
142  )->with(
143  $this->stringEndsWith('path/to/fixture/script.php')
144  );
145  $this->_object->startTransaction($this);
146  }

Field Documentation

◆ $_object

$_object
protected

Definition at line 18 of file DataFixtureTest.php.


The documentation for this class was generated from the following file: