1<?php
2/**
3 * Tests the rewriting of Kolab MIME part content to a plain content string.
4 *
5 * PHP version 5
6 *
7 * @category   Kolab
8 * @package    Kolab_Storage
9 * @subpackage UnitTests
10 * @author     Gunnar Wrobel <wrobel@pardus.de>
11 * @license    http://www.horde.org/licenses/lgpl21 LGPL 2.1
12 */
13
14/**
15 * Tests the rewriting of Kolab MIME part content to a plain content string.
16 *
17 * Copyright 2012-2017 Horde LLC (http://www.horde.org/)
18 *
19 * See the enclosed file COPYING for license information (LGPL). If you
20 * did not receive this file, see http://www.horde.org/licenses/lgpl21.
21 *
22 * @category   Kolab
23 * @package    Kolab_Storage
24 * @subpackage UnitTests
25 * @author     Gunnar Wrobel <wrobel@pardus.de>
26 * @license    http://www.horde.org/licenses/lgpl21 LGPL 2.1
27 */
28class Horde_Kolab_Storage_Unit_Object_Writer_RawTest
29extends PHPUnit_Framework_TestCase
30{
31    public function testLoad()
32    {
33        $data = "<?xml version=\"1.0\"?>\n<kolab><test/></kolab>";
34        $content = fopen('php://temp', 'r+');
35        fwrite($content, $data);
36        $raw = new Horde_Kolab_Storage_Object_Writer_Raw();
37        $object = $this->getMock('Horde_Kolab_Storage_Object');
38        $object->expects($this->once())
39            ->method('setContent')
40            ->with($content);
41        $raw->load($content, $object);
42    }
43
44    public function testSave()
45    {
46        $data = "<?xml version=\"1.0\"?>\n<kolab><test/></kolab>";
47        $content = fopen('php://temp', 'r+');
48        fwrite($content, $data);
49        $raw = new Horde_Kolab_Storage_Object_Writer_Raw();
50        $object = $this->getMock('Horde_Kolab_Storage_Object');
51        $object->expects($this->once())
52            ->method('getContent')
53            ->will($this->returnValue($content));
54        $this->assertSame(
55            $content,
56            $raw->save($object)
57        );
58    }
59}
60