class XmlEncoderTest in Zircon Profile 8
Same name in this branch
- 8 vendor/symfony/serializer/Tests/Encoder/XmlEncoderTest.php \Symfony\Component\Serializer\Tests\Encoder\XmlEncoderTest
- 8 core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php \Drupal\Tests\serialization\Unit\Encoder\XmlEncoderTest
Same name and namespace in other branches
- 8.0 core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php \Drupal\Tests\serialization\Unit\Encoder\XmlEncoderTest
@coversDefaultClass \Drupal\serialization\Encoder\XmlEncoder @group serialization
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \Drupal\Tests\PHPUnit_Framework_TestCase
- class \Drupal\Tests\serialization\Unit\Encoder\XmlEncoderTest
Expanded class hierarchy of XmlEncoderTest
File
- core/
modules/ serialization/ tests/ src/ Unit/ Encoder/ XmlEncoderTest.php, line 17 - Contains \Drupal\Tests\serialization\Unit\Encoder\XmlEncoderTest.
Namespace
Drupal\Tests\serialization\Unit\EncoderView source
class XmlEncoderTest extends UnitTestCase {
/**
* The XmlEncoder instance.
*
* @var \Drupal\serialization\Encoder\XmlEncoder
*/
protected $encoder;
/**
* @var \Symfony\Component\Serializer\Encoder\XmlEncoder|\PHPUnit_Framework_MockObject_MockObject
*/
protected $baseEncoder;
/**
* An array of test data.
*
* @var array
*/
protected $testArray = array(
'test' => 'test',
);
protected function setUp() {
$this->baseEncoder = $this
->getMock('Symfony\\Component\\Serializer\\Encoder\\XmlEncoder');
$this->encoder = new XmlEncoder();
$this->encoder
->setBaseEncoder($this->baseEncoder);
}
/**
* Tests the supportsEncoding() method.
*/
public function testSupportsEncoding() {
$this
->assertTrue($this->encoder
->supportsEncoding('xml'));
$this
->assertFalse($this->encoder
->supportsEncoding('json'));
}
/**
* Tests the supportsDecoding() method.
*/
public function testSupportsDecoding() {
$this
->assertTrue($this->encoder
->supportsDecoding('xml'));
$this
->assertFalse($this->encoder
->supportsDecoding('json'));
}
/**
* Tests the encode() method.
*/
public function testEncode() {
$this->baseEncoder
->expects($this
->once())
->method('encode')
->with($this->testArray, 'test', array())
->will($this
->returnValue('test'));
$this
->assertEquals('test', $this->encoder
->encode($this->testArray, 'test'));
}
/**
* Tests the decode() method.
*/
public function testDecode() {
$this->baseEncoder
->expects($this
->once())
->method('decode')
->with('test', 'test', array())
->will($this
->returnValue($this->testArray));
$this
->assertEquals($this->testArray, $this->encoder
->decode('test', 'test'));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed in array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
XmlEncoderTest:: |
protected | property | ||
XmlEncoderTest:: |
protected | property | The XmlEncoder instance. | |
XmlEncoderTest:: |
protected | property | An array of test data. | |
XmlEncoderTest:: |
protected | function |
Overrides UnitTestCase:: |
|
XmlEncoderTest:: |
public | function | Tests the decode() method. | |
XmlEncoderTest:: |
public | function | Tests the encode() method. | |
XmlEncoderTest:: |
public | function | Tests the supportsDecoding() method. | |
XmlEncoderTest:: |
public | function | Tests the supportsEncoding() method. |