<?php
namespace Camspiers\StatisticalClassifier\DataSource;

/**
 * Generated by PHPUnit_SkeletonGenerator 1.2.0 on 2013-03-26 at 18:06:09.
 */
class GroupedTest extends \PHPUnit_Framework_TestCase
{
    /**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     */
    protected function setUp()
    {
    }

    /**
     * Tears down the fixture, for example, closes a network connection.
     * This method is called after a test is executed.
     */
    protected function tearDown()
    {
    }

    /**
     * @covers Camspiers\StatisticalClassifier\DataSource\Grouped::addDataSource
     * @todo   Implement testAddDataSource().
     */
    public function testAddDataSource()
    {
        // Remove the following lines when you implement this test.
        $this->markTestIncomplete(
          'This test has not been implemented yet.'
        );
    }

    /**
     * @covers Camspiers\StatisticalClassifier\DataSource\Grouped::read
     * @todo   Implement testRead().
     */
    public function testRead()
    {
        // Remove the following lines when you implement this test.
        $this->markTestIncomplete(
          'This test has not been implemented yet.'
        );
    }
}

<?php

namespace Camspiers\StatisticalClassifier\DataSource;

class GroupedTest extends \PHPUnit_Framework_TestCase
{
    public function testObjectCreateViaArray()
    {
        $sources = array(
            $this->getMock(__NAMESPACE__ . '\\' . 'DataSourceInterface'),
            $this->getMock(__NAMESPACE__ . '\\' . 'DataSourceInterface')
        );
        
        $object = new Grouped($sources);
        
        $this->assertInstanceOf(__NAMESPACE__ . '\\' . 'Grouped', $object);
        
        $this->assertEquals(2, count($object->getDataSources()));
    }
    
    public function testObjectCreateViaDynamicArgs()
    {
        $object = new Grouped(
            $this->getMock(__NAMESPACE__ . '\\' . 'DataSourceInterface'),
            $this->getMock(__NAMESPACE__ . '\\' . 'DataSourceInterface')
        );

        $this->assertInstanceOf(__NAMESPACE__ . '\\' . 'Grouped', $object);

        $this->assertEquals(2, count($object->getDataSources()));
    }
    
    public function testRead()
    {
        $source1 = $this->getMock(__NAMESPACE__ . '\\' . 'DataSourceInterface');
        $source1->expects($this->once())->method('getData')->will($this->returnValue(array(
            array(
                'document' => 'Hello',
                'category' => 'super'
            )
        )));
        $source2 = $this->getMock(__NAMESPACE__ . '\\' . 'DataSourceInterface');
        $source2->expects($this->once())->method('getData')->will($this->returnValue(array(
            array(
                'document' => 'Hello',
                'category' => 'super'
            )
        )));
        
        $object = new Grouped($source1, $source2);
        
        $this->assertEquals(
            array(
                array(
                    'document' => 'Hello',
                    'category' => 'super'
                ),
                array(
                    'document' => 'Hello',
                    'category' => 'super'
                )
            ),
            $object->read()
        );
    }
}

Add test for Grouped datasource
Add test for Grouped datasource
