Refactor EntityPerPageBuilder and test

minimizes database usage in these tests

Change-Id: Ic48599263b94d0f31cf641f9a62b6e194b2cfde1
Merge branch 'noapitests' of github.com:filbertkm/Wikibase into noapitests

Conflicts:
	repo/tests/phpunit/includes/store/sql/EntityPerPageBuilderPagesFinderTest.php

Change-Id: I9527bdecbfc818f132e015a9fe3a82ab9e0f5de8