mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-11-10 03:56:12 +01:00

[CLEANUP] Rework tests to match the TDD examples

This commit is contained in:
Oliver Klee 2016-05-08 14:57:07 +02:00
parent 229ab85f0b
commit 31b1044fb5
9 changed files with 44 additions and 100 deletions

View file

@ -58,10 +58,7 @@ class TeaBeverageRepositoryTest extends \Tx_Phpunit_Database_TestCase
{
$container = $this->subject->findAll();
self::assertSame(
0,
$container->count()
);
self::assertCount(0, $container);
}
/**
@ -75,14 +72,8 @@ class TeaBeverageRepositoryTest extends \Tx_Phpunit_Database_TestCase
/** @var TeaBeverage $first */
$first = $container->getFirst();
self::assertSame(
1,
$container->count()
);
self::assertSame(
1,
$first->getUid()
);
self::assertCount(1, $container);
self::assertSame(1, $first->getUid());
}
/**

View file

@ -59,10 +59,7 @@ class TestimonialRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
{
$container = $this->subject->findAll();
self::assertSame(
0,
$container->count()
);
self::assertCount(0, $container);
}
/**
@ -76,14 +73,8 @@ class TestimonialRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
/** @var Testimonial $first */
$first = $container->getFirst();
self::assertSame(
1,
$container->count()
);
self::assertSame(
$uid,
$first->getUid()
);
self::assertCount(1, $container);
self::assertSame($uid, $first->getUid());
}
/**
@ -100,9 +91,6 @@ class TestimonialRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
$model = $this->subject->findByUid($uid);
self::assertNotNull($model);
self::assertSame(
$text,
$model->getText()
);
self::assertSame($text, $model->getText());
}
}

View file

@ -66,10 +66,7 @@ class FileUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
{
$this->subject->concatenate($this->targetFilePath, []);
self::assertSame(
'',
file_get_contents($this->targetFilePath)
);
self::assertSame('', file_get_contents($this->targetFilePath));
}
/**
@ -84,10 +81,7 @@ class FileUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
$this->subject->concatenate($this->targetFilePath, [$sourceFileName]);
self::assertSame(
'',
file_get_contents($this->targetFilePath)
);
self::assertSame('', file_get_contents($this->targetFilePath));
}
/**
@ -102,10 +96,7 @@ class FileUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
$this->subject->concatenate($this->targetFilePath, [$sourceFileName]);
self::assertSame(
$contents,
file_get_contents($this->targetFilePath)
);
self::assertSame($contents, file_get_contents($this->targetFilePath));
}
/**

View file

@ -36,10 +36,7 @@ class AdditionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
*/
public function getTitleInitiallyReturnsEmptyString()
{
self::assertSame(
'',
$this->subject->getTitle()
);
self::assertSame('', $this->subject->getTitle());
}
/**
@ -47,11 +44,10 @@ class AdditionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
*/
public function setTitleSetsTitle()
{
$this->subject->setTitle('foo bar');
$title = 'foo bar';
self::assertSame(
'foo bar',
$this->subject->getTitle()
);
$this->subject->setTitle($title);
self::assertSame($title, $this->subject->getTitle());
}
}

View file

@ -49,12 +49,11 @@ class TeaBeverageTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
*/
public function setSizeSetsSize()
{
$this->subject->setSize(1234.56);
$size = 1234.56;
self::assertSame(
1234.56,
$this->subject->getSize()
);
$this->subject->setSize($size);
self::assertSame($size, $this->subject->getSize());
}
/**

View file

@ -36,10 +36,7 @@ class TeaTypeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
*/
public function getTitleInitiallyReturnsEmptyString()
{
self::assertSame(
'',
$this->subject->getTitle()
);
self::assertSame('', $this->subject->getTitle());
}
/**
@ -47,12 +44,11 @@ class TeaTypeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
*/
public function setTitleSetsTitle()
{
$this->subject->setTitle('foo bar');
$title = 'foo bar';
self::assertSame(
'foo bar',
$this->subject->getTitle()
);
$this->subject->setTitle($title);
self::assertSame($title, $this->subject->getTitle());
}
/**
@ -60,10 +56,7 @@ class TeaTypeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
*/
public function getCaffeinatedInitiallyReturnsFalse()
{
self::assertSame(
false,
$this->subject->getCaffeinated()
);
self::assertFalse($this->subject->getCaffeinated());
}
/**
@ -72,9 +65,7 @@ class TeaTypeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
public function setCaffeinatedSetsCaffeinated()
{
$this->subject->setCaffeinated(true);
self::assertSame(
true,
$this->subject->getCaffeinated()
);
self::assertTrue($this->subject->getCaffeinated());
}
}

View file

@ -36,9 +36,7 @@ class TestimonialTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
*/
public function getDateOfPostingInitiallyReturnsNull()
{
self::assertNull(
$this->subject->getDateOfPosting()
);
self::assertNull($this->subject->getDateOfPosting());
}
/**
@ -60,10 +58,7 @@ class TestimonialTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
*/
public function getNumberOfConsumedCupsInitiallyReturnsZero()
{
self::assertSame(
0,
$this->subject->getNumberOfConsumedCups()
);
self::assertSame(0, $this->subject->getNumberOfConsumedCups());
}
/**
@ -71,12 +66,11 @@ class TestimonialTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
*/
public function setNumberOfConsumedCupsSetsNumberOfConsumedCups()
{
$this->subject->setNumberOfConsumedCups(123456);
$number = 123456;
self::assertSame(
123456,
$this->subject->getNumberOfConsumedCups()
);
$this->subject->setNumberOfConsumedCups($number);
self::assertSame($number, $this->subject->getNumberOfConsumedCups());
}
/**
@ -84,10 +78,7 @@ class TestimonialTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
*/
public function getTextInitiallyReturnsEmptyString()
{
self::assertSame(
'',
$this->subject->getText()
);
self::assertSame('', $this->subject->getText());
}
/**
@ -95,11 +86,10 @@ class TestimonialTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
*/
public function setTextSetsText()
{
$this->subject->setText('foo bar');
$text = 'foo bar';
self::assertSame(
'foo bar',
$this->subject->getText()
);
$this->subject->setText($text);
self::assertSame($text, $this->subject->getText());
}
}

View file

@ -16,6 +16,7 @@ namespace OliverKlee\Tea\Tests\Unit\Domain\Repository;
use OliverKlee\Tea\Domain\Repository\TeaBeverageRepository;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
use TYPO3\CMS\Extbase\Persistence\Repository;
/**
* Test case.
@ -43,10 +44,8 @@ class TeaBeverageRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
/**
* @test
*/
public function canBeInstantiated()
public function isRepository()
{
self::assertNotNull(
$this->subject
);
self::assertInstanceOf(Repository::class, $this->subject);
}
}

View file

@ -16,6 +16,7 @@ namespace OliverKlee\Tea\Tests\Unit\Domain\Repository;
use OliverKlee\Tea\Domain\Repository\TestimonialRepository;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
use TYPO3\CMS\Extbase\Persistence\Repository;
/**
* Test case.
@ -43,10 +44,8 @@ class TestimonialRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
/**
* @test
*/
public function canBeInstantiated()
public function isRepository()
{
self::assertNotNull(
$this->subject
);
self::assertInstanceOf(Repository::class, $this->subject);
}
}