FunctionsTest.php 777 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<?php

namespace MongoDB\Tests;

use MongoDB\Driver\ReadConcern;

/**
 * Unit tests for utility functions.
 */
class FunctionsTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider provideReadConcernsAndDocuments
     */
    public function testReadConcernAsDocument(ReadConcern $readConcern, $expectedDocument)
    {
        $this->assertEquals($expectedDocument, \MongoDB\read_concern_as_document($readConcern));
    }

    public function provideReadConcernsAndDocuments()
    {
        return [
            [ new ReadConcern, (object) [] ],
            [ new ReadConcern(ReadConcern::LOCAL), (object) ['level' => ReadConcern::LOCAL] ],
            [ new ReadConcern(ReadConcern::MAJORITY), (object) ['level' => ReadConcern::MAJORITY] ],
        ];
    }
}