Getting a jqgrid action helper to work - zend-framework

After a few searches I came across a jqgrid action helper that I could include into my Zend MVC.
However after downloading the source and trying to use it I get this error
Fatal error: Call to a member function getActionController() on a non-object in
.....
\Controller\Action\HelperBroker.php on line 299
Here is an excerpt of the helper
class My_Helper_jqgrid extends Zend_Controller_Action_Helper_Abstract {
/**
* Instance of the config file.
*
* #var Zend_Config_Ini
*/
protected $_config = null;
/**
* The instance of the database
*
* #var Zend_Db_Adapter_Abstract
*/
protected $_db = null;
/**
* The provided view
*
* #var Zend_View_Interface
*/
protected $_view = null;
/**
* The options provided to this helper
*
* #var array
*/
protected $_options = array();
/**
* #var Zend_Loader_PluginLoader
*/
public $_pluginLoader;
public function __construct(Zend_View_Interface $view = null, array $options = array()){
//$this->_db = Zend_Registry::getInstance()->get("db");
$this->_db = 'mato';
$this->_pluginLoader = new Zend_Loader_PluginLoader();
$this->_view = $view;
$this->_options = $options;
}
/**
* Strategy pattern: call helper as broker method
*
* #param string | Zend_Db_Table_Select $sql
* #param string | array $columns
*/
public function direct($sql, $columns = "*", $tableId = "id", array $options = array()) {
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setNoRender();
Zend_Controller_Action_HelperBroker::getStaticHelper('layout')->disableLayout();
$this->_options = $options;
$page = $this->getRequest()->getParam("page", 1); // get the requested page
$rows = $this->getRequest()->getParam("rows", 20); // get how many rows we want to have into the grid
$sidx = $this->getRequest()->getParam("sidx", $tableId); // get index row - i.e. user click to sort
$sord = $this->getRequest()->getParam("sord", "asc") == "desc" ? "DESC" : "ASC"; // get the direction
$response = new stdClass(); // The response object which will be translated into a json object
...............
................
return json_encode($response);
}
}
In my controller
print $this->_helper->Jqgrid("SELECT * FROM artist",
array("artist_code","artist_name","artist_album"), "id");
In my bootstrap
Zend_Controller_Action_HelperBroker::addPath(
APPLICATION_PATH . "/controllers/helpers", "My_Helper");
What am I missing?

Check this: http://zendframework.com/issues/browse/ZF-7027
I just googled for your error so I'm not sure if the link above applies.

Related

Lumen API custom error message when route not found

Is it possible to have a custom error message on Lumen when a specific route not found is made? On default it will output the 'NotFoundHttpException' page. On Laravel it's possible, not sure how to do it on Lumen. Thanks
You need to edit render() function for handling not found inside app/Exceptions/Handler.php with code given below.
<?php
namespace App\Exceptions;
use Throwable;
use Illuminate\Http\Response;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Validation\ValidationException;
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* #var array
*/
protected $dontReport = [
AuthorizationException::class,
HttpException::class,
ModelNotFoundException::class,
ValidationException::class,
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* #param \Throwable $exception
* #return void
*
* #throws \Exception
*/
public function report(Throwable $exception)
{
parent::report($exception);
}
/**
* Render an exception into an HTTP response.
*
* #param \Illuminate\Http\Request $request
* #param \Throwable $exception
* #return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
*
* #throws \Throwable
*/
public function render($request, Throwable $exception)
{
$rendered = parent::render($request, $exception);
if ($exception instanceof NotFoundHttpException) {
//You can do any change as per your requrement here for the not found exception
$message = $exception->getMessage() ? $exception->getMessage() : Response::$statusTexts[$rendered->getStatusCode()];
$exception = new NotFoundHttpException($message, $exception);
} elseif ($exception instanceof HttpException) {
$message = $exception->getMessage() ? $exception->getMessage() : Response::$statusTexts[$rendered->getStatusCode()];
$exception = new HttpException($rendered->getStatusCode(), $message);
} else {
$statusCode = Response::HTTP_INTERNAL_SERVER_ERROR;
$message = env('APP_DEBUG', false) ? $exception->getMessage() : Response::$statusTexts[$statusCode];
$exception = new HttpException($statusCode, $message);
}
// Resonse
return response()->json([
'meta' => [
'code' => $rendered->getStatusCode(),
'message' => $exception->getMessage()
]
], $rendered->getStatusCode());
}
}

The controller must return a response (Object(AppBundle\\Entity\\User) given)

I got this message "The controller must return a response (Object(App Bundle\Entity\User) given)." when i try to PATCH with postman a user password or username ... please help
BUT the username or password change ... ! i don't know why but that's working just the message is not good ...
My Userscontroller :
use AppBundle\Entity\EntityMerger;
use AppBundle\Entity\User;
use AppBundle\Exception\ResourceValidationException;
use Lexik\Bundle\JWTAuthenticationBundle\Encoder\JWTEncoderInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Validator\ConstraintViolationListInterface;
use FOS\RestBundle\Controller\Annotations as Rest;
/**
* #Security("is_anonymous() or is_authenticated()")
*/
class UsersController extends AbstractController
{
/**
* #var UserPasswordEncoderInterface
*/
private $passwordEncoder;
/**
* #var JWTEncoderInterface
*/
private $jwtEncoder;
/**
* #var EntityMerger
*/
private $entityMerger;
/**
* UsersController constructor.
* #param UserPasswordEncoderInterface $passwordEncoder
* #param JWTEncoderInterface $jwtEncoder
* #param EntityMerger $entityMerger
*/
public function __construct(UserPasswordEncoderInterface $passwordEncoder, JWTEncoderInterface $jwtEncoder, EntityMerger $entityMerger)
{
$this->passwordEncoder = $passwordEncoder;
$this->jwtEncoder = $jwtEncoder;
$this->entityMerger = $entityMerger;
}
/**
* #Rest\View()
* #Security("is_granted('show', theUser)", message="Access denied")
*/
public function getUserAction(?User $theUser)
{
if (null === $theUser) {
throw new NotFoundHttpException();
}
return $theUser;
}
/**
*
* #Rest\Post(
* path = "/users",
* name = "users_add"
* )
* #Rest\View(StatusCode=201)
* #ParamConverter(
* "user",
* converter="fos_rest.request_body",
* options={"deserializationContent"={"groups"={"Deserialize"}}}
* )
*/
public function postUserAction(User $user,
ConstraintViolationListInterface $violations)
{
if (count($violations) > 0) {
$message = 'The user is not valid: ';
foreach ($violations as $violation) {
$message .= sprintf(
"Field %s: %s ",
$violation->getPropertyPath(),
$violation->getMessage()
);
}
throw new ResourceValidationException($message);
}
$this->encodePassword($user);
$user->setRoles([User::ROLE_USER]);
$this->persistUser($user);
return $user;
}
/**
* #Rest\Patch(
* path = "/users/{theUser}",
* name= "patch_user"
* )
* #ParamConverter(
* "modifiedUser",
* converter="fos_rest.request_body",
* options={
* "validator"={"groups"={"Patch"}},
* "deserializationContext"={"groups"={"Deserialize"}}
* }
* )
* #Security("is_granted('edit', theUser)", message="Access Denied")
*/
public function patchUserAction(?User $theUser, User $modifiedUser,
ConstraintViolationListInterface $violations)
{
if (null === $theUser) {
throw new NotFoundHttpException();
}
if (empty($modifiedUser->getPassword())) {
$modifiedUser->setPassword(null);
}
if (count($violations) > 0) {
$message = 'The user is not valid: ';
foreach ($violations as $violation) {
$message .= sprintf(
"Field %s: %s",
$violation->getPropertyPath(),
$violation->getMessage()
);
}
throw new ResourceValidationException($message);
}
$this->entityMerger->merge($theUser, $modifiedUser);
$this->encodePassword($theUser);
$this->persistUser($theUser);
return $theUser;
}
/**
* #param User $user
*/
protected function encodePassword(User $user): void
{
$user->setPassword(
$this->passwordEncoder->encodePassword(
$user,
$user->getPassword()
)
);
}
/**
* #param User $user
*/
protected function persistUser(User $user): void
{
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush();
}
}
My EntityMerger:
namespace AppBundle\Entity;
use Doctrine\Common\Annotations\Reader as AnnotationReader;
use Doctrine\ORM\Mapping\Id;
class EntityMerger
{
/**
* #var AnnotationReader
*/
private $annotationReader;
public function __construct(AnnotationReader $annotationReader)
{
$this->annotationReader = $annotationReader;
}
/**
* #param $entity
* #param $changes
*/
public function merge($entity, $changes)
{
$entityClassName = get_class($entity);
if (false === $entityClassName) {
throw new \InvalidArgumentException('$entity is not a class');
}
$changesClassName = get_class($changes);
if (false == $changesClassName) {
throw new \InvalidArgumentException('$entity is not a class');
}
if (!is_a($changes, $entityClassName)) {
throw new \InvalidArgumentException("Cannot merge object of class $changesClassName with object of class $entityClassName");
}
$entityReflection = new \ReflectionObject($entity);
$changesReflection = new \ReflectionObject($changes);
foreach ($changesReflection->getProperties() as $changedProperty) {
$changedProperty->setAccessible(true);
$changedPropertyValue = $changedProperty->getValue($changes);
if(null === $changedPropertyValue) {
continue;
}
if (!$entityReflection->hasProperty($changedProperty->getName())) {
continue;
}
$entityProperty = $entityReflection->getProperty($changedProperty->getName());
$annotation = $this->annotationReader->getPropertyAnnotation($entityProperty, Id::class);
if (null !== $annotation) {
continue;
}
$entityProperty->setAccessible(true);
$entityProperty->setValue($entity, $changedPropertyValue);
}
}
}
The message correctly states that you are not returning a response object.
From the manual, The only requirement for a controller is to return a Response object
If you want to return an object you could return JSON:
return $this->json(['user' => $theUser]);
This is just a guess from your code, because your question does not state what you want to return.

Too many Redirects with Controller

When I try to define my routes with an ImagesController, I get a "site redirected you too many times" error when going to what should be the index. I'm stumped. Am I over-tired and not seeing something obvious?
web.php
Route::prefix('images')->group(function(){
Route::post('add-tag', 'ImagesController#addTag');
Route::get('test', 'ImagesController#index');
});
When I access /images/test, the controller responds correctly. When I have it defined as '' or / it redirects too much. I'm not setting them simultaneously.
Route::prefix('images')->group(function(){
Route::post('add-tag', 'ImagesController#addTag');
// like this:
Route::get('', 'ImagesController#index');
// or like the following:
Route::get('/', 'ImagesController#index');
});
I've even tried to define /images before the prefix group to no avail. images/test is fine in this case.
Route::get('images', 'ImagesController#index');
Route::prefix('images')->group(function(){
Route::post('add-tag', 'ImagesController#addTag');
Route::get('test', 'ImagesController#index');
});
ImagesController.php
namespace App\Http\Controllers;
use \Auth;
use App\Helpers;
use App\Image;
use App\Tag;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Symfony\Component\Console\Helper\Helper;
class ImagesController extends Controller
{
private $sortBy = [
'created_at',
'updated_at',
'orig_name',
'orig_size'
];
private $defaultSortBy = 'created_at';
private $defaultOrder = 'desc';
/**
* #param Request $request
* #return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(Request $request)
{
$sort = $request->get('sort', $this->defaultSortBy);
$sort = in_array($sort, $this->sortBy) ? $sort : 'created_at';
$order = $request->get('order', $this->defaultOrder);
$order = $order == 'desc' ? 'desc' : 'asc';
$images = Image::orderBy($sort, $order)
->whereQuestionable(0)
->wherePrivate(0)
->paginate(config('image.images_per_page'));
if ($images !== null && $sort !== $this->defaultSortBy) {
$images->appends(['sort' => $sort]);
}
if ($images !== null && $order !== $this->defaultOrder) {
$images->appends(['order' => $order]);
}
return view(
'images.index',
[
'images' => $images,
'sort' => $sort,
'order' => $order
]
);
}
/**
* Show the form for creating a new resource.
*
* #return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* #param \Illuminate\Http\Request $request
* #return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* #param \Illuminate\Http\Request $request
* #param int $id
* #return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
//this function works correctly, but I suppose it may be interfering?
public function addTag(Request $request)
{
Log::debug(print_r($request->all(), true));
$error = '';
$uid = trim($request->input('uid', ''));
$newTag = Helpers::prepTag($request->input('tag', ''));
if (!Auth::check()){
$error .= 'You can only add tags to images if you are logged in.';
} else if ($uid === '' || $newTag === '') {
$error .= 'UID and tag cannot be empty';
} else {
$image = Image::whereUid($uid)->unQuestionable()->first();
$currentTags = [];
if (count($image->tags)){
foreach ($image->tags as $currentTag) {
$currentTags[$currentTag->id] = $currentTag->tag;
}
}
if ($image === null) {
$error .= "Image $uid was not found.";
} else {
$tag = Tag::firstOrNew(['tag'=>$newTag]);
if ($tag->ip == '') {
$tag->ip = $request->getClientIp();
$tag->user_id = Auth::check() ? Auth::user()->id : 5;
$tag->save();
}
//\Log::info(print_r($currentTags, true));
//\Log::info(print_r($tag, true));
$addTag = !(bool)isset($currentTags[$tag->id]);
$image->tags()->sync([$tag->id], false);
}
}
if ($request->ajax()) {
if ($error !== '') {
return response()->json(['message' => $error],400);
}
return response()->json(['tagId' => $tag->id, 'imageUid' => $image->uid, 'tag' => $tag->tag, 'isAdmin' => true, 'addTag' => $addTag]);
} else {
if ($error !== '') {
Helpers::alert(3, $error, 'Tag Not Added');
}
return redirect('/');
}
}
}
As I have a model named Images implicit binding was interfering with my defined routes for a controller with the name ImagesController, and applying the prefix /images. After changing the name in the routing to image this issue went away.

How can I get the TYPO3 "appearance" media images by using "ViewHelper"?

thanks for reading and answering...
I have some TYPO3 gridelements in my TYPO3 pagecontent.
Each gridelement has a tab "appearance", where I define an image file.
The database relation from tt_content to the media image are in sys_file_reference.
My question is how can I get this image file in my fluid template by using the ViewHelper and the uid of my gridelement?
I wrote an little ViewHelper (tested on 7.6, but should not need so much changes for 8.7) to get referenced images for an newsletter layout:
<?php
namespace Vendor\Extension\ViewHelpers;
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\Resource\FileRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Resource\FileReference;
use TYPO3\CMS\Core\Resource\Exception;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
class ImagesReferencesViewHelper extends AbstractViewHelper implements CompilableInterface
{
/**
* Iterates through elements of $each and renders child nodes
*
* #param int $uid The ID of the element
* #param string $table The Referenced table name
* #param string $fieldName The Referenced field name
* #param string $as The name of the iteration variable
* #param string $key The name of the variable to store the current array key
* #param boolean $reverse If enabled, the iterator will start with the last element and proceed reversely
* #param string $iteration The name of the variable to store iteration information (index, cycle, isFirst, isLast, isEven, isOdd)
* #param string $link The name of the variable to store link
*
* #return string Rendered string
* #api
*/
public function render($uid, $table = 'tt_content', $fieldName = 'assets', $as, $key = '', $reverse = false, $iteration = null, $link = null)
{
return self::renderStatic($this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext);
}
/**
* #param array $arguments
* #param \Closure $renderChildrenClosure
* #param \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
*
* #return string
* #throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
*/
static public function renderStatic(array $arguments, \Closure $renderChildrenClosure, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
{
$templateVariableContainer = $renderingContext->getTemplateVariableContainer();
if ($arguments['uid'] === null || $arguments['table'] === null || $arguments['fieldName'] === null) {
return '';
}
/** #var FileRepository $fileRepository */
$fileRepository = GeneralUtility::makeInstance(FileRepository::class);
$images = array();
try {
$images = $fileRepository->findByRelation($arguments['table'], $arguments['fieldName'], $arguments['uid']);
} catch (Exception $e) {
/** #var \TYPO3\CMS\Core\Log\Logger $logger */
$logger = GeneralUtility::makeInstance(LogManager::class)->getLogger();
$logger->warning('The file-reference with uid "' . $arguments['uid'] . '" could not be found and won\'t be included in frontend output');
}
if (is_object($images) && !$images instanceof \Traversable) {
throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception('ImagesReferencesViewHelper only supports arrays and objects implementing \Traversable interface', 1248728393);
}
if ($arguments['reverse'] === true) {
// array_reverse only supports arrays
if (is_object($images)) {
$images = iterator_to_array($images);
}
$images = array_reverse($images);
}
$iterationData = array(
'index' => 0,
'cycle' => 1,
'total' => count($images)
);
$output = '';
foreach ($images as $keyValue => $singleElement) {
$templateVariableContainer->add($arguments['as'], $singleElement);
/** #var FileReference $singleElement */
if ($arguments['link'] !== null && $singleElement->getLink()) {
$link = $singleElement->getLink();
/** #var ContentObjectRenderer $contentObject */
$contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
$newLink = $contentObject->typoLink_URL(array('parameter' => $link));
$templateVariableContainer->add($arguments['link'], $newLink);
}
if ($arguments['key'] !== '') {
$templateVariableContainer->add($arguments['key'], $keyValue);
}
if ($arguments['iteration'] !== null) {
$iterationData['isFirst'] = $iterationData['cycle'] === 1;
$iterationData['isLast'] = $iterationData['cycle'] === $iterationData['total'];
$iterationData['isEven'] = $iterationData['cycle'] % 2 === 0;
$iterationData['isOdd'] = !$iterationData['isEven'];
$templateVariableContainer->add($arguments['iteration'], $iterationData);
$iterationData['index']++;
$iterationData['cycle']++;
}
$output .= $renderChildrenClosure();
$templateVariableContainer->remove($arguments['as']);
if ($arguments['link'] !== null && $singleElement->getLink()) {
$templateVariableContainer->remove($arguments['link']);
}
if ($arguments['key'] !== '') {
$templateVariableContainer->remove($arguments['key']);
}
if ($arguments['iteration'] !== null) {
$templateVariableContainer->remove($arguments['iteration']);
}
}
return $output;
}
}

PHPUnit Zend_Test_PHPUnit_DatabaseTestCase fails to truncate table

I am setting up some db integration testing using Zend_Test_PHPUnit_DatabaseTestCase.
My tests run but the db tables do not get truncated so an add test fails assertion - as the xml I provide as a dataset does not match the db can anybody suggest why
TestCase
class ArtworkDBTest extends DatabaseTestCase
{
public function testAddArtwork()
{
$data=array("artwork_name"=>'test',"description"=>'test',"imgpath"=>'test',"size"=>'test',"price_information"=>'test',"category"=>1,"artwork_order"=>1);
$mockedLog=$this->getMock("Log",array("log"));
$artwork = new shop_Artwork($mockedLog,Zend_Db_Table_Abstract::getDefaultAdapter());
$artwork->addArtwork($data);
$this->assertDataSetsMatchXML('artwork-add.xml', $dataSet);
}
}
Database testing setup code (adapted from dragonbe and ibuildings tutorials)
abstract class DatabaseTestCase extends Zend_Test_PHPUnit_DatabaseTestCase
{
const DEFAULT_CONNECTION_SCHEMA = 'main';
protected $_connectionMock;
private $__configuration = NULL;
protected $_connectionSchema = self::DEFAULT_CONNECTION_SCHEMA;
protected $_seedFilesPath;
protected $dataSet;
public function __construct()
{
$this->dataSet = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet($this->getConnection());
$this->dataSet->addTable('artwork','Select* from artwork');
$this->dataSet->addTable('login','Select *from login');
$this->dataSet->addTable('category','Select *from category');
}
public function getConfiguration()
{
if ($this->__configuration == NULL) {
$this->__configuration = new Zend_Config_Ini(TEST_PATH . '/application/configs/tests.ini');
}
return $this->__configuration;
}
public function getSeedFilesPath()
{
if ($this->_seedFilesPath == NULL) {
$this->_seedFilesPath = $this->getConfiguration()->tests->seeds->folder;
}
return rtrim($this->_seedFilesPath, '/') . '/';
}
protected function getConnection()
{
if ($this->_connectionMock == NULL) {
$dbAdapterName = $this->getConfiguration()->tests->dbadapter;
$dbAdapterParams = $this->getConfiguration()->tests->dbparams->toArray();
$connection = Zend_Db::factory($dbAdapterName, $dbAdapterParams);
$this->_connectionMock = $this->createZendDbConnection(
$connection, $this->_connectionSchema
);
Zend_Db_Table_Abstract::setDefaultAdapter($connection);
}
return $this->_connectionMock;
}
protected function getDataSet()
{
return $this->createFlatXMLDataSet(TEST_PATH . '/fixtures/models/artwork-seed.xml');
}
/**
* Convert a Rowset to a Dataset
*
* #param Zend_Db_Table_Rowset_Abstract $rowset
* #param string $tableName
* #return PHPUnit_Extensions_Database_DataSet_DefaultDataSet
*/
public function convertRowsetToDataSet($rowset, $tableName = NULL)
{
$rowsetDataSet = new Zend_Test_PHPUnit_Db_DataSet_DbRowset($rowset, $tableName);
return new PHPUnit_Extensions_Database_DataSet_DefaultDataSet(array($rowsetDataSet));
}
/**
* Convert a Record to a Dataset
*
* #param array $data
* #param string $tableName
* #return PHPUnit_Extensions_Database_DataSet_DefaultDataSet
*/
public function convertRecordToDataSet(Array $data, $tableName)
{
$rowset = new Zend_Db_Table_Rowset(array('data' => array($data)));
return $this->convertRowsetToDataSet($rowset, $tableName);
}
/**
* Compare dataset with data stored in the file
*
* #param string $filename
* #param PHPUnit_Extensions_Database_DataSet_IDataSet $expected
* #return boolean
*/
public function assertDataSetsMatchXML($filename, PHPUnit_Extensions_Database_DataSet_IDataSet $actual)
{
if (empty($filename) || !is_string($filename))
throw new InvalidArgumentException(
'Second parameter "filename" is not a valid string.'
);
$expected = $this->createFlatXmlDataSet($this->getSeedFilesPath() . $filename);
return $this->assertDataSetsEqual($expected, $actual);
}
}
The answer was running parent::setUp(); inside the test class's setUp() method