Core and composer updates

This commit is contained in:
Rob Davies 2017-07-03 16:47:07 +01:00
parent a82634bb98
commit 62cac30480
1118 changed files with 21770 additions and 6306 deletions

View file

@ -3,6 +3,9 @@
namespace Drupal\Tests\serialization\Unit\Encoder;
use Drupal\serialization\Encoder\XmlEncoder;
use Symfony\Component\Serializer\Encoder\XmlEncoder as BaseXmlEncoder;
use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
use Symfony\Component\Serializer\Serializer;
use Drupal\Tests\UnitTestCase;
/**
@ -31,7 +34,7 @@ class XmlEncoderTest extends UnitTestCase {
protected $testArray = ['test' => 'test'];
protected function setUp() {
$this->baseEncoder = $this->getMock('Symfony\Component\Serializer\Encoder\XmlEncoder');
$this->baseEncoder = $this->getMock(BaseXmlEncoder::class);
$this->encoder = new XmlEncoder();
$this->encoder->setBaseEncoder($this->baseEncoder);
}
@ -76,4 +79,26 @@ class XmlEncoderTest extends UnitTestCase {
$this->assertEquals($this->testArray, $this->encoder->decode('test', 'test'));
}
/**
* @covers ::getBaseEncoder
*/
public function testDefaultEncoderHasSerializer() {
// The serializer should be set on the Drupal encoder, which should then
// set it on our default encoder.
$encoder = new XmlEncoder();
$serialzer = new Serializer([new GetSetMethodNormalizer()]);
$encoder->setSerializer($serialzer);
$base_encoder = $encoder->getBaseEncoder();
$this->assertInstanceOf(BaseXmlEncoder::class, $base_encoder);
// Test the encoder.
$base_encoder->encode(['a' => new TestObject()], 'xml');
}
}
class TestObject {
public function getA() {
return 'A';
}
}