<commit_before><?php

namespace ExcelAnt\PhpExcel;

use PHPExcel_Worksheet;
use PHPExcel_Worksheet_RowDimension;
use PHPExcel_Worksheet_ColumnDimension;

use ExcelAnt\PhpExcel\Workbook;
use ExcelAnt\PhpExcel\Sheet;
use ExcelAnt\Table\Table;
use ExcelAnt\Coordinate\Coordinate;
use ExcelAnt\Cell\Cell;

class SheetTest extends \PHPUnit_Framework_TestCase
{
    public function testRawClass()
    {
        $sheet = $this->createSheet();

        $this->assertInstanceOf("PHPExcel_Worksheet", $sheet->getRawClass());
    }

    public function testSetAndGetTitle()
    {
        $phpExcelWorksheet = $this->getPhpExcelWorksheetMock();
        $phpExcelWorksheet->expects($this->any())
            ->method('setTitle')
            ->will($this->returnValue($phpExcelWorksheet));
        $phpExcelWorksheet->expects($this->any())
            ->method('getTitle')
            ->will($this->returnValue('Foo'));

        $sheet = $this->createSheet(null, $phpExcelWorksheet);
        $sheet->setTitle('Foo');

        $this->assertEquals('Foo', $sheet->getTitle());
    }

    public function testAddAndGetTable()
    {
        $table = new Table();

        $sheet = $this->createSheet();
        $sheet->addTable($table, new Coordinate(1, 1));

        $this->assertCount(1, $sheet->getTables());
    }

    public function testAddAndGetCell()
    {
        $sheet = $this->createSheet();
        $sheet->addCell(new Cell(), new Coordinate(1, 1));

        $this->assertCount(1, $sheet->getCells());
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testSetRowHeightWithWrongHeightParameter()
    {
        $sheet = $this->createSheet();
        $sheet->setRowHeight('foo', 1);
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testSetRowHeightWithWrongIdParameter()
    {
        $sheet = $this->createSheet();
        $sheet->setRowHeight(1, 'foo');
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testGetRowHeightWithWrongParameter()
    {
        $sheet = $this->createSheet();
        $sheet->getRowHeight('foo');
    }

    public function testSetAndGetRowHeight()
    {
        $phpExcelWorksheet = $this->getPhpExcelWorksheetMock();
        $phpExcelRowDimension = $this->getPhpExcelRowDimensionMock();

        $phpExcelRowDimension->expects($this->any())
            ->method('setRowHeight')
            ->will($this->returnValue($phpExcelRowDimension));
        $phpExcelRowDimension->expects($this->any())
            ->method('getRowHeight')
            ->will($this->returnValue(3));

        $phpExcelWorksheet->expects($this->any())
            ->method('getRowDimension')
            ->will($this->returnValue($phpExcelRowDimension));

        $sheet = $this->createSheet(null, $phpExcelWorksheet);
        $sheet->setRowHeight(3, 1);

        $this->assertEquals(3, $sheet->getRowHeight(1));
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testSetColumnWidthWithWrongWidthParameter()
    {
        $sheet = $this->createSheet();
        $sheet->setColumnWidth('foo', 1);
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testSetColumnWidthWithWrongIdParameter()
    {
        $sheet = $this->createSheet();
        $sheet->setColumnWidth(1, 'foo');
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testGetColumnWidthWithWrongParameter()
    {
        $sheet = $this->createSheet();
        $sheet->getColumnWidth('foo');
    }

    public function testSetAndGetColumnWidth()
    {
        $phpExcelWorksheet = $this->getPhpExcelWorksheetMock();
        $phpExcelRowDimension = $this->getPhpExcelColumnDimensionMock();

        $phpExcelRowDimension->expects($this->any())
            ->method('setWidth')
            ->will($this->returnValue($phpExcelRowDimension));
        $phpExcelRowDimension->expects($this->any())
            ->method('getWidth')
            ->will($this->returnValue(3));

        $phpExcelWorksheet->expects($this->any())
            ->method('getColumnDimension')
            ->will($this->returnValue($phpExcelRowDimension));

        $sheet = $this->createSheet(null, $phpExcelWorksheet);
        $sheet->setColumnWidth(3, 1);

        $this->assertEquals(3, $sheet->getColumnWidth(1));
    }

    /**
     * Create a Sheet
     *
     * @param  Mock_Workbook
     * @param  Mock_PHPExcel_Worksheet $phpExcelWorksheet<commit_msg>Code review continue<commit_after><?php

namespace ExcelAnt\PhpExcel;

use PHPExcel_Worksheet;
use PHPExcel_Worksheet_RowDimension;
use PHPExcel_Worksheet_ColumnDimension;

use ExcelAnt\PhpExcel\Workbook;
use ExcelAnt\PhpExcel\Sheet;
use ExcelAnt\Table\Table;
use ExcelAnt\Coordinate\Coordinate;
use ExcelAnt\Cell\Cell;

class SheetTest extends \PHPUnit_Framework_TestCase
{
    public function testRawClass()
    {
        $sheet = $this->createSheet();

        $this->assertInstanceOf("PHPExcel_Worksheet", $sheet->getRawClass());
    }

    public function testSetAndGetTitle()
    {
        $phpExcelWorksheet = $this->getPhpExcelWorksheetMock();
        $phpExcelWorksheet->expects($this->any())
            ->method('setTitle')
            ->will($this->returnValue($phpExcelWorksheet));
        $phpExcelWorksheet->expects($this->any())
            ->method('getTitle')
            ->will($this->returnValue('Foo'));

        $sheet = $this->createSheet(null, $phpExcelWorksheet)->setTitle('Foo');

        $this->assertEquals('Foo', $sheet->getTitle());
    }

    public function testAddAndGetTable()
    {
        $table = new Table();

        $sheet = $this->createSheet()->addTable($table, new Coordinate(1, 1));

        $this->assertCount(1, $sheet->getTables());
    }

    public function testAddAndGetCell()
    {
        $sheet = $this->createSheet()->addCell(new Cell(), new Coordinate(1, 1));

        $this->assertCount(1, $sheet->getCells());
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testSetRowHeightWithWrongHeightParameter()
    {
        $sheet = $this->createSheet()->setRowHeight('foo', 1);
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testSetRowHeightWithWrongIdParameter()
    {
        $sheet = $this->createSheet()->setRowHeight(1, 'foo');
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testGetRowHeightWithWrongParameter()
    {
        $sheet = $this->createSheet()->getRowHeight('foo');
    }

    public function testSetAndGetRowHeight()
    {
        $phpExcelWorksheet = $this->getPhpExcelWorksheetMock();
        $phpExcelRowDimension = $this->getPhpExcelRowDimensionMock();

        $phpExcelRowDimension->expects($this->any())
            ->method('setRowHeight')
            ->will($this->returnValue($phpExcelRowDimension));
        $phpExcelRowDimension->expects($this->any())
            ->method('getRowHeight')
            ->will($this->returnValue(3));

        $phpExcelWorksheet->expects($this->any())
            ->method('getRowDimension')
            ->will($this->returnValue($phpExcelRowDimension));

        $sheet = $this->createSheet(null, $phpExcelWorksheet)->setRowHeight(3, 1);

        $this->assertEquals(3, $sheet->getRowHeight(1));
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testSetColumnWidthWithWrongWidthParameter()
    {
        $sheet = $this->createSheet()->setColumnWidth('foo', 1);
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testSetColumnWidthWithWrongIdParameter()
    {
        $sheet = $this->createSheet()->setColumnWidth(1, 'foo');
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testGetColumnWidthWithWrongParameter()
    {
        $sheet = $this->createSheet()->getColumnWidth('foo');
    }

    public function testSetAndGetColumnWidth()
    {
        $phpExcelWorksheet = $this->getPhpExcelWorksheetMock();
        $phpExcelRowDimension = $this->getPhpExcelColumnDimensionMock();

        $phpExcelRowDimension->expects($this->any())
            ->method('setWidth')
            ->will($this->returnValue($phpExcelRowDimension));
        $phpExcelRowDimension->expects($this->any())
            ->method('getWidth')
            ->will($this->returnValue(3));

        $phpExcelWorksheet->expects($this->any())
            ->method('getColumnDimension')
            ->will($this->returnValue($phpExcelRowDimension));

        $sheet = $this->createSheet(null, $phpExcelWorksheet)->setColumnWidth(3, 1);

        $this->assertEquals(3, $sheet->getColumnWidth(1));
    }

    /**
     * Create a Sheet
     *
     * @param  Mock_Workbook
     * @param  Mock_PHPExcel_Worksheet $phpExcelWorksheet
{'fraction_non_alphanumeric': 0.14722689075630252, 'fraction_numerical': 0.004481792717086834, 'mean_word_length': 2.9600709849157054, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 163, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5883597', 'n_tokens_mistral': 2666, 'n_tokens_neox': 2529, 'n_words': 348}