mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-11-26 08: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(); $container = $this->subject->findAll();
self::assertSame( self::assertCount(0, $container);
0,
$container->count()
);
} }
/** /**
@ -75,14 +72,8 @@ class TeaBeverageRepositoryTest extends \Tx_Phpunit_Database_TestCase
/** @var TeaBeverage $first */ /** @var TeaBeverage $first */
$first = $container->getFirst(); $first = $container->getFirst();
self::assertSame( self::assertCount(1, $container);
1, self::assertSame(1, $first->getUid());
$container->count()
);
self::assertSame(
1,
$first->getUid()
);
} }
/** /**

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -36,9 +36,7 @@ class TestimonialTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
*/ */
public function getDateOfPostingInitiallyReturnsNull() public function getDateOfPostingInitiallyReturnsNull()
{ {
self::assertNull( self::assertNull($this->subject->getDateOfPosting());
$this->subject->getDateOfPosting()
);
} }
/** /**
@ -60,10 +58,7 @@ class TestimonialTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
*/ */
public function getNumberOfConsumedCupsInitiallyReturnsZero() public function getNumberOfConsumedCupsInitiallyReturnsZero()
{ {
self::assertSame( self::assertSame(0, $this->subject->getNumberOfConsumedCups());
0,
$this->subject->getNumberOfConsumedCups()
);
} }
/** /**
@ -71,12 +66,11 @@ class TestimonialTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
*/ */
public function setNumberOfConsumedCupsSetsNumberOfConsumedCups() public function setNumberOfConsumedCupsSetsNumberOfConsumedCups()
{ {
$this->subject->setNumberOfConsumedCups(123456); $number = 123456;
self::assertSame( $this->subject->setNumberOfConsumedCups($number);
123456,
$this->subject->getNumberOfConsumedCups() self::assertSame($number, $this->subject->getNumberOfConsumedCups());
);
} }
/** /**
@ -84,10 +78,7 @@ class TestimonialTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
*/ */
public function getTextInitiallyReturnsEmptyString() public function getTextInitiallyReturnsEmptyString()
{ {
self::assertSame( self::assertSame('', $this->subject->getText());
'',
$this->subject->getText()
);
} }
/** /**
@ -95,11 +86,10 @@ class TestimonialTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
*/ */
public function setTextSetsText() public function setTextSetsText()
{ {
$this->subject->setText('foo bar'); $text = 'foo bar';
self::assertSame( $this->subject->setText($text);
'foo bar',
$this->subject->getText() 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 OliverKlee\Tea\Domain\Repository\TeaBeverageRepository;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface; use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
use TYPO3\CMS\Extbase\Persistence\Repository;
/** /**
* Test case. * Test case.
@ -43,10 +44,8 @@ class TeaBeverageRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
/** /**
* @test * @test
*/ */
public function canBeInstantiated() public function isRepository()
{ {
self::assertNotNull( self::assertInstanceOf(Repository::class, $this->subject);
$this->subject
);
} }
} }

View file

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