Skip to content
This repository was archived by the owner on Jan 19, 2023. It is now read-only.

WIP: EndToEnd Test #5

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,11 @@ jobs:
- name: "Install locked dependencies with composer"
run: "composer install --no-interaction --no-progress --no-suggest"

- name: "RenderZendViewRector EndToEnd-Test"
run: |
vendor/bin/rector process tests/EndToEnd/RenderZendViewTest.php -c tests/EndToEnd/zend2rocket-controller-test.yaml
diff tests/EndToEnd/RenderZendViewTest.php tests/EndToEnd/RenderZendViewTest.expected.php

- name: "Run unit tests with phpunit/phpunit"
run: "vendor/bin/phpunit tests/"

70 changes: 70 additions & 0 deletions tests/EndToEnd/RenderZendViewTest.expected.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php


class ProductController {

public function TestFunction()
{
// do something
$this->setNoRender();
// do something
echo "124";
}

public function autocompletedAction()
{
// do something
$this->setNoRender();
// do something
echo "124";
}

public function getArticleInfoFunction()
{
echo "124";
// do something
}

public function getArticleDetailsAction()
{
// do something
echo "124";
return $this->currentZendViewResult();
}

public function multipleImplicitReturnsAction()
{
for ($i = 0; $i < 5; $i++) {
if (i > 2) {
return false;
}
return true;
}
return true;
return $this->currentZendViewResult();
}

public function autocompleteAction()
{
$this->setNoRender(true);
$this->disableLayout();
$this->setNoRender(true);

$searchTerm = $this->getParam('term');

$artMapper = new Application_Model_Mapper_Article();
$all = $artMapper->fetchAllNamesForAutocomplete($searchTerm);

$articleNames = array();

foreach ($all as $article) {
$articleNames[] = array(
'id' => $article->getArtid(),
'label' => $article->getName());
}

$this->json($articleNames);
}
}

?>
68 changes: 68 additions & 0 deletions tests/EndToEnd/RenderZendViewTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php


class ProductController {

public function TestFunction()
{
// do something
$this->setNoRender();
// do something
echo "124";
}

public function autocompletedAction()
{
// do something
$this->setNoRender();
// do something
echo "124";
}

public function getArticleInfoFunction()
{
echo "124";
// do something
}

public function getArticleDetailsAction()
{
// do something
echo "124";
}

public function multipleImplicitReturnsAction()
{
for ($i = 0; $i < 5; $i++) {
if (i > 2) {
return false;
}
return true;
}
return true;
}

public function autocompleteAction()
{
$this->setNoRender(true);
$this->disableLayout();
$this->setNoRender(true);

$searchTerm = $this->getParam('term');

$artMapper = new Application_Model_Mapper_Article();
$all = $artMapper->fetchAllNamesForAutocomplete($searchTerm);

$articleNames = array();

foreach ($all as $article) {
$articleNames[] = array(
'id' => $article->getArtid(),
'label' => $article->getName());
}

$this->json($articleNames);
}
}

?>
118 changes: 118 additions & 0 deletions tests/EndToEnd/RenderZendViewTestFull.expected.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?php


class ProductController {

public function TestFunction()
{
// do something
$this->setNoRender();
// do something
echo "124";
}

public function autocompletedAction()
{
// do something
$this->setNoRender();
// do something
echo "124";
}

public function getArticleInfoFunction()
{
echo "124";
// do something
}

public function getArticleDetailsAction()
{
echo "124";
// do something
return $this->currentZendViewResult();
}

/* -> rector issue: https://github.com/rectorphp/rector/issues/2994 / https://github.com/rectorphp/rector/issues/2991
public function getArticleBackDetailsAction()
{
// do something
}
*/

public function multipleImplicitReturnsAction()
{
for ($i = 0; $i < 5; $i++) {
if (i > 2) {
return false;
}
return true;
}
return true;
return $this->currentZendViewResult();
}

/**
* count artfarbenids in aset of articles (used in basket and stock)
*
* @param unknown $array
* @return multitype:number
*/
/* -> rector issue: https://github.com/rectorphp/rector/issues/2989
protected function _getCountByArtfarbeid($array)
{
$count = array();
foreach ($array as $item) {
if (array_key_exists($item->getArtfarbeid(), $count)) {
$count[$item->getArtfarbeid()] ++;
} else {
$count[$item->getArtfarbeid()] = 1;
}
}
return $count;
}
*/

public function getArticleInfoAction()
{
echo "124";
// do something
//bestaende
$vetechs = array(
//Transferdruck
4 => array(
'description' => $translations[$this->t_getLanguage()->getKuerzel()][4],
'image' => '/img/vearten/ink.svg'
),
//Stick
5 => array(
'description' => $translations[$this->t_getLanguage()->getKuerzel()][5],
'image' => '/img/vearten/bestickbar.svg'
)
);
return $this->currentZendViewResult();
}

public function autocompleteAction()
{
$this->setNoRender(true);
$this->disableLayout();
$this->setNoRender(true);

$searchTerm = $this->getParam('term');

$artMapper = new Application_Model_Mapper_Article();
$all = $artMapper->fetchAllNamesForAutocomplete($searchTerm);

$articleNames = array();

foreach ($all as $article) {
$articleNames[] = array(
'id' => $article->getArtid(),
'label' => $article->getName());
}

$this->json($articleNames);
}
}

?>
114 changes: 114 additions & 0 deletions tests/EndToEnd/RenderZendViewTestFull.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php


class ProductController {

public function TestFunction()
{
// do something
$this->setNoRender();
// do something
echo "124";
}

public function autocompletedAction()
{
// do something
$this->setNoRender();
// do something
echo "124";
}

public function getArticleInfoFunction()
{
echo "124";
// do something
}

public function getArticleDetailsAction()
{
echo "124";
return $this->currentZendViewResult();
// do something
}

/* -> rector issue: https://github.com/rectorphp/rector/issues/2994 / https://github.com/rectorphp/rector/issues/2991
* public function getArticleBackDetailsAction()
{
// do something
}
*/
public function multipleImplicitReturnsAction()
{
for ($i = 0; $i < 5; $i++) {
if (i > 2) {
return false;
}
return true;
}
return true;
return $this->currentZendViewResult();
}

/**
* count artfarbenids in aset of articles (used in basket and stock)
*
* @param unknown $array
* @return multitype :number
*//* -> rector issue: https://github.com/rectorphp/rector/issues/2989
protected function _getCountByArtfarbeid($array)
{
$count = array();
foreach ($array as $item) {
if (array_key_exists($item->getArtfarbeid(), $count)) {
$count[$item->getArtfarbeid()] ++;
} else {
$count[$item->getArtfarbeid()] = 1;
}
}
return $count;
}
*/
public function getArticleInfoAction()
{
echo "124";
// do something
//bestaende
$vetechs = array(
4 => array(
'description' => $translations[$this->t_getLanguage()->getKuerzel()][4],
'image' => '/img/vearten/ink.svg'
),

5 => array(
'description' => $translations[$this->t_getLanguage()->getKuerzel()][5],
'image' => '/img/vearten/bestickbar.svg'
)
);
return $this->currentZendViewResult();
}

public function autocompleteAction()
{
$this->setNoRender(true);
$this->disableLayout();
$this->setNoRender(true);

$searchTerm = $this->getParam('term');

$artMapper = new Application_Model_Mapper_Article();
$all = $artMapper->fetchAllNamesForAutocomplete($searchTerm);

$articleNames = array();

foreach ($all as $article) {
$articleNames[] = array(
'id' => $article->getArtid(),
'label' => $article->getName());
}

$this->json($articleNames);
}
}

?>
Loading