| Conditions | 2 |
| Paths | 2 |
| Total Lines | 53 |
| Code Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 14 | public function testLiveJobsGridSource() |
||
| 15 | { |
||
| 16 | $liveJobsGridSource = $this->getLiveGridSource(); |
||
| 17 | self::assertNull($liveJobsGridSource->getDefaultSort()); |
||
| 18 | self::assertFalse($liveJobsGridSource->isRunning()); |
||
| 19 | $count = $liveJobsGridSource->getCount(); |
||
| 20 | $records = $liveJobsGridSource->getRecords(); |
||
| 21 | self::assertEquals(0, $count); |
||
| 22 | self::assertEmpty($records); |
||
| 23 | |||
| 24 | $job = new BaseJobManagerTest::$jobClass(BaseJobManagerTest::$worker, false, null); |
||
| 25 | $job->fibonacci(1); |
||
| 26 | |||
| 27 | $count = $liveJobsGridSource->getCount(); |
||
| 28 | $records = $liveJobsGridSource->getRecords(); |
||
| 29 | self::assertEquals(1, $count); |
||
| 30 | self::assertNotEmpty($records); |
||
| 31 | |||
| 32 | $job = new BaseJobManagerTest::$jobClass(BaseJobManagerTest::$worker, false, null); |
||
| 33 | $job->fibonacci(1); |
||
| 34 | |||
| 35 | $count = $liveJobsGridSource->getCount(); |
||
| 36 | $records = $liveJobsGridSource->getRecords(); |
||
| 37 | self::assertEquals(2, $count); |
||
| 38 | self::assertNotEmpty($records); |
||
| 39 | |||
| 40 | $columns = $liveJobsGridSource->getColumns(); |
||
| 41 | self::assertNotEmpty($columns); |
||
| 42 | foreach ($columns as $column) { |
||
| 43 | self::assertFalse($column->getOption('sortable')); |
||
| 44 | } |
||
| 45 | |||
| 46 | $liveJobsGridSource->setRunning(true); |
||
| 47 | self::assertTrue($liveJobsGridSource->isRunning()); |
||
| 48 | $count = $liveJobsGridSource->getCount(); |
||
| 49 | $records = $liveJobsGridSource->getRecords(); |
||
| 50 | self::assertEquals(0, $count); |
||
| 51 | self::assertEmpty($records); |
||
| 52 | |||
| 53 | BaseJobManagerTest::$jobManager->getJob(); |
||
| 54 | |||
| 55 | $count = $liveJobsGridSource->getCount(); |
||
| 56 | $records = $liveJobsGridSource->getRecords(); |
||
| 57 | self::assertEquals(1, $count); |
||
| 58 | self::assertNotEmpty($records); |
||
| 59 | |||
| 60 | BaseJobManagerTest::$jobManager->getJob(); |
||
| 61 | |||
| 62 | $count = $liveJobsGridSource->getCount(); |
||
| 63 | $records = $liveJobsGridSource->getRecords(); |
||
| 64 | self::assertEquals(2, $count); |
||
| 65 | self::assertNotEmpty($records); |
||
| 66 | } |
||
| 67 | } |
||
| 68 |