@@ -32,19 +32,19 @@ discard block |
||
| 32 | 32 | protected function configure() |
| 33 | 33 | { |
| 34 | 34 | $names = ''; |
| 35 | - $aimeos = new \Aimeos\Bootstrap( array() ); |
|
| 36 | - $cntlPaths = $aimeos->getCustomPaths( 'controller/jobs' ); |
|
| 37 | - $controllers = \Aimeos\Controller\Jobs::get( $this->getBareContext(), $aimeos, $cntlPaths ); |
|
| 35 | + $aimeos = new \Aimeos\Bootstrap(array()); |
|
| 36 | + $cntlPaths = $aimeos->getCustomPaths('controller/jobs'); |
|
| 37 | + $controllers = \Aimeos\Controller\Jobs::get($this->getBareContext(), $aimeos, $cntlPaths); |
|
| 38 | 38 | |
| 39 | - foreach( $controllers as $key => $controller ) { |
|
| 40 | - $names .= str_pad( $key, 30 ) . $controller->getName() . PHP_EOL; |
|
| 39 | + foreach ($controllers as $key => $controller) { |
|
| 40 | + $names .= str_pad($key, 30).$controller->getName().PHP_EOL; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - $this->setName( self::$defaultName ); |
|
| 44 | - $this->setDescription( 'Executes the job controllers' ); |
|
| 45 | - $this->addArgument( 'jobs', InputArgument::REQUIRED, 'One or more job controller names like "admin/job customer/email/watch"' ); |
|
| 46 | - $this->addArgument( 'site', InputArgument::OPTIONAL, 'Site codes to execute the jobs for like "default unittest" (none for all)' ); |
|
| 47 | - $this->setHelp( "Available jobs are:\n" . $names ); |
|
| 43 | + $this->setName(self::$defaultName); |
|
| 44 | + $this->setDescription('Executes the job controllers'); |
|
| 45 | + $this->addArgument('jobs', InputArgument::REQUIRED, 'One or more job controller names like "admin/job customer/email/watch"'); |
|
| 46 | + $this->addArgument('site', InputArgument::OPTIONAL, 'Site codes to execute the jobs for like "default unittest" (none for all)'); |
|
| 47 | + $this->setHelp("Available jobs are:\n".$names); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | |
@@ -54,32 +54,32 @@ discard block |
||
| 54 | 54 | * @param InputInterface $input Input object |
| 55 | 55 | * @param OutputInterface $output Output object |
| 56 | 56 | */ |
| 57 | - protected function execute( InputInterface $input, OutputInterface $output ) |
|
| 57 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
| 58 | 58 | { |
| 59 | 59 | $context = $this->getContext(); |
| 60 | 60 | $process = $context->getProcess(); |
| 61 | - $aimeos = $this->getContainer()->get( 'aimeos' )->get(); |
|
| 61 | + $aimeos = $this->getContainer()->get('aimeos')->get(); |
|
| 62 | 62 | |
| 63 | - $jobs = explode( ' ', $input->getArgument( 'jobs' ) ); |
|
| 64 | - $localeManager = \Aimeos\MShop::create( $context, 'locale' ); |
|
| 63 | + $jobs = explode(' ', $input->getArgument('jobs')); |
|
| 64 | + $localeManager = \Aimeos\MShop::create($context, 'locale'); |
|
| 65 | 65 | |
| 66 | - foreach( $this->getSiteItems( $context, $input ) as $siteItem ) |
|
| 66 | + foreach ($this->getSiteItems($context, $input) as $siteItem) |
|
| 67 | 67 | { |
| 68 | - $localeItem = $localeManager->bootstrap( $siteItem->getCode(), '', '', false ); |
|
| 69 | - $localeItem->setLanguageId( null ); |
|
| 70 | - $localeItem->setCurrencyId( null ); |
|
| 68 | + $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false); |
|
| 69 | + $localeItem->setLanguageId(null); |
|
| 70 | + $localeItem->setCurrencyId(null); |
|
| 71 | 71 | |
| 72 | - $context->setLocale( $localeItem ); |
|
| 72 | + $context->setLocale($localeItem); |
|
| 73 | 73 | |
| 74 | - $output->writeln( sprintf( 'Executing the Aimeos jobs for "<info>%s</info>"', $siteItem->getCode() ) ); |
|
| 74 | + $output->writeln(sprintf('Executing the Aimeos jobs for "<info>%s</info>"', $siteItem->getCode())); |
|
| 75 | 75 | |
| 76 | - foreach( $jobs as $jobname ) |
|
| 76 | + foreach ($jobs as $jobname) |
|
| 77 | 77 | { |
| 78 | - $fcn = function( $context, $aimeos, $jobname ) { |
|
| 79 | - \Aimeos\Controller\Jobs::create( $context, $aimeos, $jobname )->run(); |
|
| 78 | + $fcn = function($context, $aimeos, $jobname) { |
|
| 79 | + \Aimeos\Controller\Jobs::create($context, $aimeos, $jobname)->run(); |
|
| 80 | 80 | }; |
| 81 | 81 | |
| 82 | - $process->start( $fcn, [$context, $aimeos, $jobname], true ); |
|
| 82 | + $process->start($fcn, [$context, $aimeos, $jobname], true); |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
@@ -96,15 +96,15 @@ discard block |
||
| 96 | 96 | { |
| 97 | 97 | $ctx = new \Aimeos\MShop\Context\Item\Standard(); |
| 98 | 98 | |
| 99 | - $conf = new \Aimeos\MW\Config\PHPArray( array(), array() ); |
|
| 100 | - $ctx->setConfig( $conf ); |
|
| 99 | + $conf = new \Aimeos\MW\Config\PHPArray(array(), array()); |
|
| 100 | + $ctx->setConfig($conf); |
|
| 101 | 101 | |
| 102 | - $locale = \Aimeos\MShop::create( $ctx, 'locale' )->createItem(); |
|
| 103 | - $locale->setLanguageId( 'en' ); |
|
| 104 | - $ctx->setLocale( $locale ); |
|
| 102 | + $locale = \Aimeos\MShop::create($ctx, 'locale')->createItem(); |
|
| 103 | + $locale->setLanguageId('en'); |
|
| 104 | + $ctx->setLocale($locale); |
|
| 105 | 105 | |
| 106 | - $i18n = new \Aimeos\MW\Translation\None( 'en' ); |
|
| 107 | - $ctx->setI18n( array( 'en' => $i18n ) ); |
|
| 106 | + $i18n = new \Aimeos\MW\Translation\None('en'); |
|
| 107 | + $ctx->setI18n(array('en' => $i18n)); |
|
| 108 | 108 | |
| 109 | 109 | return $ctx; |
| 110 | 110 | } |
@@ -119,19 +119,19 @@ discard block |
||
| 119 | 119 | { |
| 120 | 120 | $container = $this->getContainer(); |
| 121 | 121 | $aimeos = $container->get('aimeos')->get(); |
| 122 | - $context = $container->get( 'aimeos.context' )->get( false, 'command' ); |
|
| 122 | + $context = $container->get('aimeos.context')->get(false, 'command'); |
|
| 123 | 123 | |
| 124 | - $tmplPaths = $aimeos->getCustomPaths( 'controller/jobs/templates' ); |
|
| 125 | - $tmplPaths = array_merge( $tmplPaths, $aimeos->getCustomPaths( 'client/html/templates' ) ); |
|
| 126 | - $view = $container->get('aimeos.view')->create( $context, $tmplPaths ); |
|
| 124 | + $tmplPaths = $aimeos->getCustomPaths('controller/jobs/templates'); |
|
| 125 | + $tmplPaths = array_merge($tmplPaths, $aimeos->getCustomPaths('client/html/templates')); |
|
| 126 | + $view = $container->get('aimeos.view')->create($context, $tmplPaths); |
|
| 127 | 127 | |
| 128 | - $langManager = \Aimeos\MShop::create( $context, 'locale/language' ); |
|
| 129 | - $langids = array_keys( $langManager->searchItems( $langManager->createSearch( true ) ) ); |
|
| 130 | - $i18n = $this->getContainer()->get( 'aimeos.i18n' )->get( $langids ); |
|
| 128 | + $langManager = \Aimeos\MShop::create($context, 'locale/language'); |
|
| 129 | + $langids = array_keys($langManager->searchItems($langManager->createSearch(true))); |
|
| 130 | + $i18n = $this->getContainer()->get('aimeos.i18n')->get($langids); |
|
| 131 | 131 | |
| 132 | - $context->setEditor( 'aimeos:jobs' ); |
|
| 133 | - $context->setView( $view ); |
|
| 134 | - $context->setI18n( $i18n ); |
|
| 132 | + $context->setEditor('aimeos:jobs'); |
|
| 133 | + $context->setView($view); |
|
| 134 | + $context->setI18n($i18n); |
|
| 135 | 135 | |
| 136 | 136 | return $context; |
| 137 | 137 | } |
@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | protected function configure() |
| 34 | 34 | { |
| 35 | - $this->setName( self::$defaultName ); |
|
| 36 | - $this->setDescription( 'Initialize or update the Aimeos database tables' ); |
|
| 37 | - $this->addArgument( 'site', InputArgument::OPTIONAL, 'Site for updating database entries', 'default' ); |
|
| 38 | - $this->addArgument( 'tplsite', InputArgument::OPTIONAL, 'Template site for creating or updating database entries', 'default' ); |
|
| 39 | - $this->addOption( 'option', null, InputOption::VALUE_REQUIRED, 'Optional setup configuration, name and value are separated by ":" like "setup/default/demo:1"', array() ); |
|
| 40 | - $this->addOption( 'action', null, InputOption::VALUE_REQUIRED, 'Action name that should be executed, i.e. "migrate", "rollback", "clean"', 'migrate' ); |
|
| 41 | - $this->addOption( 'task', null, InputOption::VALUE_REQUIRED, 'Name of the setup task that should be executed', null ); |
|
| 35 | + $this->setName(self::$defaultName); |
|
| 36 | + $this->setDescription('Initialize or update the Aimeos database tables'); |
|
| 37 | + $this->addArgument('site', InputArgument::OPTIONAL, 'Site for updating database entries', 'default'); |
|
| 38 | + $this->addArgument('tplsite', InputArgument::OPTIONAL, 'Template site for creating or updating database entries', 'default'); |
|
| 39 | + $this->addOption('option', null, InputOption::VALUE_REQUIRED, 'Optional setup configuration, name and value are separated by ":" like "setup/default/demo:1"', array()); |
|
| 40 | + $this->addOption('action', null, InputOption::VALUE_REQUIRED, 'Action name that should be executed, i.e. "migrate", "rollback", "clean"', 'migrate'); |
|
| 41 | + $this->addOption('task', null, InputOption::VALUE_REQUIRED, 'Name of the setup task that should be executed', null); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | |
@@ -48,44 +48,44 @@ discard block |
||
| 48 | 48 | * @param InputInterface $input Input object |
| 49 | 49 | * @param OutputInterface $output Output object |
| 50 | 50 | */ |
| 51 | - protected function execute( InputInterface $input, OutputInterface $output ) |
|
| 51 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
| 52 | 52 | { |
| 53 | - $ctx = $this->getContainer()->get( 'aimeos.context' )->get( false, 'command' ); |
|
| 54 | - $ctx->setEditor( 'aimeos:setup' ); |
|
| 53 | + $ctx = $this->getContainer()->get('aimeos.context')->get(false, 'command'); |
|
| 54 | + $ctx->setEditor('aimeos:setup'); |
|
| 55 | 55 | |
| 56 | 56 | $config = $ctx->getConfig(); |
| 57 | - $site = $input->getArgument( 'site' ); |
|
| 58 | - $tplsite = $input->getArgument( 'tplsite' ); |
|
| 57 | + $site = $input->getArgument('site'); |
|
| 58 | + $tplsite = $input->getArgument('tplsite'); |
|
| 59 | 59 | |
| 60 | - $config->set( 'setup/site', $site ); |
|
| 61 | - $dbconfig = $this->getDbConfig( $config ); |
|
| 62 | - $this->setOptions( $config, $input ); |
|
| 60 | + $config->set('setup/site', $site); |
|
| 61 | + $dbconfig = $this->getDbConfig($config); |
|
| 62 | + $this->setOptions($config, $input); |
|
| 63 | 63 | |
| 64 | - \Aimeos\MShop::cache( false ); |
|
| 65 | - \Aimeos\MAdmin::cache( false ); |
|
| 64 | + \Aimeos\MShop::cache(false); |
|
| 65 | + \Aimeos\MAdmin::cache(false); |
|
| 66 | 66 | |
| 67 | - $taskPaths = $this->getContainer()->get( 'aimeos' )->get()->getSetupPaths( $tplsite ); |
|
| 68 | - $manager = new \Aimeos\MW\Setup\Manager\Multiple( $ctx->getDatabaseManager(), $dbconfig, $taskPaths, $ctx ); |
|
| 67 | + $taskPaths = $this->getContainer()->get('aimeos')->get()->getSetupPaths($tplsite); |
|
| 68 | + $manager = new \Aimeos\MW\Setup\Manager\Multiple($ctx->getDatabaseManager(), $dbconfig, $taskPaths, $ctx); |
|
| 69 | 69 | |
| 70 | - $output->writeln( sprintf( 'Initializing or updating the Aimeos database tables for site <info>%1$s</info>', $site ) ); |
|
| 70 | + $output->writeln(sprintf('Initializing or updating the Aimeos database tables for site <info>%1$s</info>', $site)); |
|
| 71 | 71 | |
| 72 | - if( ( $task = $input->getOption( 'task' ) ) && is_array( $task ) ) { |
|
| 73 | - $task = reset( $task ); |
|
| 72 | + if (($task = $input->getOption('task')) && is_array($task)) { |
|
| 73 | + $task = reset($task); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - switch( $input->getOption( 'action' ) ) |
|
| 76 | + switch ($input->getOption('action')) |
|
| 77 | 77 | { |
| 78 | 78 | case 'migrate': |
| 79 | - $manager->migrate( $task ); |
|
| 79 | + $manager->migrate($task); |
|
| 80 | 80 | break; |
| 81 | 81 | case 'rollback': |
| 82 | - $manager->rollback( $task ); |
|
| 82 | + $manager->rollback($task); |
|
| 83 | 83 | break; |
| 84 | 84 | case 'clean': |
| 85 | - $manager->clean( $task ); |
|
| 85 | + $manager->clean($task); |
|
| 86 | 86 | break; |
| 87 | 87 | default: |
| 88 | - throw new \Exception( sprintf( 'Invalid setup action "%1$s"', $input->getOption( 'action' ) ) ); |
|
| 88 | + throw new \Exception(sprintf('Invalid setup action "%1$s"', $input->getOption('action'))); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
@@ -96,14 +96,14 @@ discard block |
||
| 96 | 96 | * @param \Aimeos\MW\Config\Iface $conf Config object |
| 97 | 97 | * @return array Multi-dimensional associative list of database configuration parameters |
| 98 | 98 | */ |
| 99 | - protected function getDbConfig( \Aimeos\MW\Config\Iface $conf ) |
|
| 99 | + protected function getDbConfig(\Aimeos\MW\Config\Iface $conf) |
|
| 100 | 100 | { |
| 101 | - $dbconfig = $conf->get( 'resource', array() ); |
|
| 101 | + $dbconfig = $conf->get('resource', array()); |
|
| 102 | 102 | |
| 103 | - foreach( $dbconfig as $rname => $dbconf ) |
|
| 103 | + foreach ($dbconfig as $rname => $dbconf) |
|
| 104 | 104 | { |
| 105 | - if( strncmp( $rname, 'db', 2 ) !== 0 ) { |
|
| 106 | - unset( $dbconfig[$rname] ); |
|
| 105 | + if (strncmp($rname, 'db', 2) !== 0) { |
|
| 106 | + unset($dbconfig[$rname]); |
|
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | |
@@ -119,12 +119,12 @@ discard block |
||
| 119 | 119 | * @param array Associative list of database configurations |
| 120 | 120 | * @throws \RuntimeException If the format of the options is invalid |
| 121 | 121 | */ |
| 122 | - protected function setOptions( \Aimeos\MW\Config\Iface $conf, InputInterface $input ) |
|
| 122 | + protected function setOptions(\Aimeos\MW\Config\Iface $conf, InputInterface $input) |
|
| 123 | 123 | { |
| 124 | - foreach( (array) $input->getOption( 'option' ) as $option ) |
|
| 124 | + foreach ((array) $input->getOption('option') as $option) |
|
| 125 | 125 | { |
| 126 | - list( $name, $value ) = explode( ':', $option ); |
|
| 127 | - $conf->set( str_replace( '\\', '/', $name ), $value ); |
|
| 126 | + list($name, $value) = explode(':', $option); |
|
| 127 | + $conf->set(str_replace('\\', '/', $name), $value); |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | protected function configure() |
| 33 | 33 | { |
| 34 | - $this->setName( self::$defaultName ); |
|
| 35 | - $this->setDescription( 'Clears the content cache' ); |
|
| 36 | - $this->addArgument( 'site', InputArgument::OPTIONAL, 'Site codes to clear the cache like "default unittest" (none for all)' ); |
|
| 34 | + $this->setName(self::$defaultName); |
|
| 35 | + $this->setDescription('Clears the content cache'); |
|
| 36 | + $this->addArgument('site', InputArgument::OPTIONAL, 'Site codes to clear the cache like "default unittest" (none for all)'); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | |
@@ -43,26 +43,26 @@ discard block |
||
| 43 | 43 | * @param InputInterface $input Input object |
| 44 | 44 | * @param OutputInterface $output Output object |
| 45 | 45 | */ |
| 46 | - protected function execute( InputInterface $input, OutputInterface $output ) |
|
| 46 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
| 47 | 47 | { |
| 48 | - $context = $this->getContainer()->get( 'aimeos.context' )->get( false, 'command' ); |
|
| 49 | - $context->setEditor( 'aimeos:cache' ); |
|
| 48 | + $context = $this->getContainer()->get('aimeos.context')->get(false, 'command'); |
|
| 49 | + $context->setEditor('aimeos:cache'); |
|
| 50 | 50 | |
| 51 | - $localeManager = \Aimeos\MShop::create( $context, 'locale' ); |
|
| 51 | + $localeManager = \Aimeos\MShop::create($context, 'locale'); |
|
| 52 | 52 | |
| 53 | - foreach( $this->getSiteItems( $context, $input ) as $siteItem ) |
|
| 53 | + foreach ($this->getSiteItems($context, $input) as $siteItem) |
|
| 54 | 54 | { |
| 55 | - $localeItem = $localeManager->bootstrap( $siteItem->getCode(), '', '', false ); |
|
| 55 | + $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false); |
|
| 56 | 56 | |
| 57 | 57 | $lcontext = clone $context; |
| 58 | - $lcontext->setLocale( $localeItem ); |
|
| 58 | + $lcontext->setLocale($localeItem); |
|
| 59 | 59 | |
| 60 | - $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard( $lcontext ); |
|
| 61 | - $lcontext->setCache( $cache ); |
|
| 60 | + $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard($lcontext); |
|
| 61 | + $lcontext->setCache($cache); |
|
| 62 | 62 | |
| 63 | - $output->writeln( sprintf( 'Clearing the Aimeos cache for site <info>%1$s</info>', $siteItem->getCode() ) ); |
|
| 63 | + $output->writeln(sprintf('Clearing the Aimeos cache for site <info>%1$s</info>', $siteItem->getCode())); |
|
| 64 | 64 | |
| 65 | - \Aimeos\MAdmin::create( $lcontext, 'cache' )->getCache()->clear(); |
|
| 65 | + \Aimeos\MAdmin::create($lcontext, 'cache')->getCache()->clear(); |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -10,17 +10,17 @@ |
||
| 10 | 10 | { |
| 11 | 11 | protected function setUp() |
| 12 | 12 | { |
| 13 | - \Aimeos\MShop::cache( false ); |
|
| 14 | - \Aimeos\Controller\Frontend::cache( false ); |
|
| 13 | + \Aimeos\MShop::cache(false); |
|
| 14 | + \Aimeos\Controller\Frontend::cache(false); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | public function testSelectComponent() |
| 19 | 19 | { |
| 20 | 20 | $client = static::createClient(); |
| 21 | - $client->request( 'GET', '/unittest/de/EUR/test/localeselectcomponent' ); |
|
| 21 | + $client->request('GET', '/unittest/de/EUR/test/localeselectcomponent'); |
|
| 22 | 22 | |
| 23 | - $this->assertEquals( 200, $client->getResponse()->getStatusCode() ); |
|
| 24 | - $this->assertContains( 'aimeos locale-select', $client->getResponse()->getContent() ); |
|
| 23 | + $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
|
| 24 | + $this->assertContains('aimeos locale-select', $client->getResponse()->getContent()); |
|
| 25 | 25 | } |
| 26 | 26 | } |
@@ -10,68 +10,68 @@ |
||
| 10 | 10 | { |
| 11 | 11 | protected function setUp() |
| 12 | 12 | { |
| 13 | - \Aimeos\MShop::cache( false ); |
|
| 14 | - \Aimeos\Controller\Frontend::cache( false ); |
|
| 13 | + \Aimeos\MShop::cache(false); |
|
| 14 | + \Aimeos\Controller\Frontend::cache(false); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | public function testAccount() |
| 19 | 19 | { |
| 20 | 20 | $client = static::createClient(); |
| 21 | - $client->request( 'GET', '/unittest/de/EUR/myaccount/' ); |
|
| 21 | + $client->request('GET', '/unittest/de/EUR/myaccount/'); |
|
| 22 | 22 | |
| 23 | - $this->assertContains( 'aimeos account-profile', $client->getResponse()->getContent() ); |
|
| 24 | - $this->assertContains( 'aimeos account-history', $client->getResponse()->getContent() ); |
|
| 25 | - $this->assertContains( 'aimeos account-favorite', $client->getResponse()->getContent() ); |
|
| 26 | - $this->assertContains( 'aimeos account-watch', $client->getResponse()->getContent() ); |
|
| 23 | + $this->assertContains('aimeos account-profile', $client->getResponse()->getContent()); |
|
| 24 | + $this->assertContains('aimeos account-history', $client->getResponse()->getContent()); |
|
| 25 | + $this->assertContains('aimeos account-favorite', $client->getResponse()->getContent()); |
|
| 26 | + $this->assertContains('aimeos account-watch', $client->getResponse()->getContent()); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | public function testDownload() |
| 31 | 31 | { |
| 32 | 32 | $client = static::createClient(); |
| 33 | - $client->request( 'GET', '/unittest/de/EUR/myaccount/download/0' ); |
|
| 33 | + $client->request('GET', '/unittest/de/EUR/myaccount/download/0'); |
|
| 34 | 34 | |
| 35 | - $this->assertEquals( 401, $client->getResponse()->getStatusCode() ); |
|
| 35 | + $this->assertEquals(401, $client->getResponse()->getStatusCode()); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | public function testFavoriteComponent() |
| 40 | 40 | { |
| 41 | 41 | $client = static::createClient(); |
| 42 | - $client->request( 'GET', '/unittest/de/EUR/test/accountfavoritecomponent' ); |
|
| 42 | + $client->request('GET', '/unittest/de/EUR/test/accountfavoritecomponent'); |
|
| 43 | 43 | |
| 44 | - $this->assertEquals( 200, $client->getResponse()->getStatusCode() ); |
|
| 45 | - $this->assertContains( 'aimeos account-favorite', $client->getResponse()->getContent() ); |
|
| 44 | + $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
|
| 45 | + $this->assertContains('aimeos account-favorite', $client->getResponse()->getContent()); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | |
| 49 | 49 | public function testHistoryComponent() |
| 50 | 50 | { |
| 51 | 51 | $client = static::createClient(); |
| 52 | - $client->request( 'GET', '/unittest/de/EUR/test/accounthistorycomponent' ); |
|
| 52 | + $client->request('GET', '/unittest/de/EUR/test/accounthistorycomponent'); |
|
| 53 | 53 | |
| 54 | - $this->assertEquals( 200, $client->getResponse()->getStatusCode() ); |
|
| 55 | - $this->assertContains( 'aimeos account-history', $client->getResponse()->getContent() ); |
|
| 54 | + $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
|
| 55 | + $this->assertContains('aimeos account-history', $client->getResponse()->getContent()); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | public function testProfileComponent() |
| 60 | 60 | { |
| 61 | 61 | $client = static::createClient(); |
| 62 | - $client->request( 'GET', '/unittest/de/EUR/test/accountprofilecomponent' ); |
|
| 62 | + $client->request('GET', '/unittest/de/EUR/test/accountprofilecomponent'); |
|
| 63 | 63 | |
| 64 | - $this->assertEquals( 200, $client->getResponse()->getStatusCode() ); |
|
| 65 | - $this->assertContains( 'aimeos account-profile', $client->getResponse()->getContent() ); |
|
| 64 | + $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
|
| 65 | + $this->assertContains('aimeos account-profile', $client->getResponse()->getContent()); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | public function testWatchComponent() |
| 70 | 70 | { |
| 71 | 71 | $client = static::createClient(); |
| 72 | - $client->request( 'GET', '/unittest/de/EUR/test/accountwatchcomponent' ); |
|
| 72 | + $client->request('GET', '/unittest/de/EUR/test/accountwatchcomponent'); |
|
| 73 | 73 | |
| 74 | - $this->assertEquals( 200, $client->getResponse()->getStatusCode() ); |
|
| 75 | - $this->assertContains( 'aimeos account-watch', $client->getResponse()->getContent() ); |
|
| 74 | + $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
|
| 75 | + $this->assertContains('aimeos account-watch', $client->getResponse()->getContent()); |
|
| 76 | 76 | } |
| 77 | 77 | } |
@@ -9,82 +9,82 @@ discard block |
||
| 9 | 9 | { |
| 10 | 10 | protected function setUp() |
| 11 | 11 | { |
| 12 | - \Aimeos\MShop::cache( false ); |
|
| 13 | - \Aimeos\Controller\Frontend::cache( false ); |
|
| 12 | + \Aimeos\MShop::cache(false); |
|
| 13 | + \Aimeos\Controller\Frontend::cache(false); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | public function testOptionsAction() |
| 18 | 18 | { |
| 19 | 19 | $client = static::createClient(); |
| 20 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
| 20 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
| 21 | 21 | $response = $client->getResponse(); |
| 22 | 22 | |
| 23 | - $json = json_decode( $response->getContent(), true ); |
|
| 23 | + $json = json_decode($response->getContent(), true); |
|
| 24 | 24 | |
| 25 | - $this->assertNotNull( $json ); |
|
| 26 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 27 | - $this->assertArrayHasKey( 'resources', $json['meta'] ); |
|
| 28 | - $this->assertGreaterThan( 1, count( $json['meta']['resources'] ) ); |
|
| 25 | + $this->assertNotNull($json); |
|
| 26 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 27 | + $this->assertArrayHasKey('resources', $json['meta']); |
|
| 28 | + $this->assertGreaterThan(1, count($json['meta']['resources'])); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | public function testPutAction() |
| 33 | 33 | { |
| 34 | 34 | $client = static::createClient(); |
| 35 | - $client->request( 'PUT', '/unittest/de/EUR/jsonapi/basket' ); |
|
| 35 | + $client->request('PUT', '/unittest/de/EUR/jsonapi/basket'); |
|
| 36 | 36 | $response = $client->getResponse(); |
| 37 | 37 | |
| 38 | - $json = json_decode( $response->getContent(), true ); |
|
| 38 | + $json = json_decode($response->getContent(), true); |
|
| 39 | 39 | |
| 40 | - $this->assertNotNull( $json ); |
|
| 41 | - $this->assertEquals( 403, $response->getStatusCode() ); |
|
| 42 | - $this->assertArrayHasKey( 'errors', $json ); |
|
| 40 | + $this->assertNotNull($json); |
|
| 41 | + $this->assertEquals(403, $response->getStatusCode()); |
|
| 42 | + $this->assertArrayHasKey('errors', $json); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | public function testGetAttributeAction() |
| 47 | 47 | { |
| 48 | 48 | $client = static::createClient(); |
| 49 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/attribute', [] ); |
|
| 49 | + $client->request('GET', '/unittest/de/EUR/jsonapi/attribute', []); |
|
| 50 | 50 | $response = $client->getResponse(); |
| 51 | 51 | |
| 52 | - $json = json_decode( $response->getContent(), true ); |
|
| 52 | + $json = json_decode($response->getContent(), true); |
|
| 53 | 53 | |
| 54 | - $this->assertNotNull( $json ); |
|
| 55 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 56 | - $this->assertEquals( 26, $json['meta']['total'] ); |
|
| 57 | - $this->assertEquals( 25, count( $json['data'] ) ); |
|
| 54 | + $this->assertNotNull($json); |
|
| 55 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 56 | + $this->assertEquals(26, $json['meta']['total']); |
|
| 57 | + $this->assertEquals(25, count($json['data'])); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | |
| 61 | 61 | public function testGetCatalogAction() |
| 62 | 62 | { |
| 63 | 63 | $client = static::createClient(); |
| 64 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/catalog', [] ); |
|
| 64 | + $client->request('GET', '/unittest/de/EUR/jsonapi/catalog', []); |
|
| 65 | 65 | $response = $client->getResponse(); |
| 66 | 66 | |
| 67 | - $json = json_decode( $response->getContent(), true ); |
|
| 67 | + $json = json_decode($response->getContent(), true); |
|
| 68 | 68 | |
| 69 | - $this->assertNotNull( $json ); |
|
| 70 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 71 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
| 72 | - $this->assertEquals( 4, count( $json['data'] ) ); |
|
| 69 | + $this->assertNotNull($json); |
|
| 70 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 71 | + $this->assertEquals(1, $json['meta']['total']); |
|
| 72 | + $this->assertEquals(4, count($json['data'])); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
| 76 | 76 | public function testGetLocaleAction() |
| 77 | 77 | { |
| 78 | 78 | $client = static::createClient(); |
| 79 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/locale', [] ); |
|
| 79 | + $client->request('GET', '/unittest/de/EUR/jsonapi/locale', []); |
|
| 80 | 80 | $response = $client->getResponse(); |
| 81 | 81 | |
| 82 | - $json = json_decode( $response->getContent(), true ); |
|
| 82 | + $json = json_decode($response->getContent(), true); |
|
| 83 | 83 | |
| 84 | - $this->assertNotNull( $json ); |
|
| 85 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 86 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
| 87 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
| 84 | + $this->assertNotNull($json); |
|
| 85 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 86 | + $this->assertEquals(1, $json['meta']['total']); |
|
| 87 | + $this->assertEquals(1, count($json['data'])); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | |
@@ -93,58 +93,58 @@ discard block |
||
| 93 | 93 | $client = static::createClient(); |
| 94 | 94 | |
| 95 | 95 | $params = ['filter' => ['f_search' => 'Cafe Noire Cap']]; |
| 96 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/product', $params ); |
|
| 96 | + $client->request('GET', '/unittest/de/EUR/jsonapi/product', $params); |
|
| 97 | 97 | $response = $client->getResponse(); |
| 98 | 98 | |
| 99 | - $json = json_decode( $response->getContent(), true ); |
|
| 99 | + $json = json_decode($response->getContent(), true); |
|
| 100 | 100 | |
| 101 | - $this->assertNotNull( $json ); |
|
| 102 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 103 | - $this->assertEquals( 2, $json['meta']['total'] ); |
|
| 104 | - $this->assertEquals( 2, count( $json['data'] ) ); |
|
| 105 | - $this->assertArrayHasKey( 'id', $json['data'][0] ); |
|
| 106 | - $this->assertEquals( 'CNC', $json['data'][0]['attributes']['product.code'] ); |
|
| 101 | + $this->assertNotNull($json); |
|
| 102 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 103 | + $this->assertEquals(2, $json['meta']['total']); |
|
| 104 | + $this->assertEquals(2, count($json['data'])); |
|
| 105 | + $this->assertArrayHasKey('id', $json['data'][0]); |
|
| 106 | + $this->assertEquals('CNC', $json['data'][0]['attributes']['product.code']); |
|
| 107 | 107 | |
| 108 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/product?id=' . $json['data'][0]['id'] ); |
|
| 108 | + $client->request('GET', '/unittest/de/EUR/jsonapi/product?id='.$json['data'][0]['id']); |
|
| 109 | 109 | $response = $client->getResponse(); |
| 110 | 110 | |
| 111 | - $json = json_decode( $response->getContent(), true ); |
|
| 111 | + $json = json_decode($response->getContent(), true); |
|
| 112 | 112 | |
| 113 | - $this->assertNotNull( $json ); |
|
| 114 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 115 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
| 116 | - $this->assertArrayHasKey( 'id', $json['data'] ); |
|
| 117 | - $this->assertEquals( 'CNC', $json['data']['attributes']['product.code'] ); |
|
| 113 | + $this->assertNotNull($json); |
|
| 114 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 115 | + $this->assertEquals(1, $json['meta']['total']); |
|
| 116 | + $this->assertArrayHasKey('id', $json['data']); |
|
| 117 | + $this->assertEquals('CNC', $json['data']['attributes']['product.code']); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
| 121 | 121 | public function testGetServiceAction() |
| 122 | 122 | { |
| 123 | 123 | $client = static::createClient(); |
| 124 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/service', [] ); |
|
| 124 | + $client->request('GET', '/unittest/de/EUR/jsonapi/service', []); |
|
| 125 | 125 | $response = $client->getResponse(); |
| 126 | 126 | |
| 127 | - $json = json_decode( $response->getContent(), true ); |
|
| 127 | + $json = json_decode($response->getContent(), true); |
|
| 128 | 128 | |
| 129 | - $this->assertNotNull( $json ); |
|
| 130 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 131 | - $this->assertEquals( 4, $json['meta']['total'] ); |
|
| 132 | - $this->assertEquals( 4, count( $json['data'] ) ); |
|
| 129 | + $this->assertNotNull($json); |
|
| 130 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 131 | + $this->assertEquals(4, $json['meta']['total']); |
|
| 132 | + $this->assertEquals(4, count($json['data'])); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | |
| 136 | 136 | public function testGetStockAction() |
| 137 | 137 | { |
| 138 | 138 | $client = static::createClient(); |
| 139 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/stock', ['filter' => ['s_prodcode' => ['CNC', 'CNE']]] ); |
|
| 139 | + $client->request('GET', '/unittest/de/EUR/jsonapi/stock', ['filter' => ['s_prodcode' => ['CNC', 'CNE']]]); |
|
| 140 | 140 | $response = $client->getResponse(); |
| 141 | 141 | |
| 142 | - $json = json_decode( $response->getContent(), true ); |
|
| 142 | + $json = json_decode($response->getContent(), true); |
|
| 143 | 143 | |
| 144 | - $this->assertNotNull( $json ); |
|
| 145 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 146 | - $this->assertEquals( 2, $json['meta']['total'] ); |
|
| 147 | - $this->assertEquals( 2, count( $json['data'] ) ); |
|
| 144 | + $this->assertNotNull($json); |
|
| 145 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 146 | + $this->assertEquals(2, $json['meta']['total']); |
|
| 147 | + $this->assertEquals(2, count($json['data'])); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | |
@@ -152,24 +152,24 @@ discard block |
||
| 152 | 152 | { |
| 153 | 153 | $client = static::createClient(); |
| 154 | 154 | |
| 155 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
| 156 | - $optJson = json_decode( $client->getResponse()->getContent(), true ); |
|
| 157 | - $this->assertGreaterThan( 8, count( $optJson['meta']['resources'] ) ); |
|
| 155 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
| 156 | + $optJson = json_decode($client->getResponse()->getContent(), true); |
|
| 157 | + $this->assertGreaterThan(8, count($optJson['meta']['resources'])); |
|
| 158 | 158 | |
| 159 | 159 | // catalog root |
| 160 | - $client->request( 'GET', $optJson['meta']['resources']['catalog'], ['include' => 'catalog'] ); |
|
| 161 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 162 | - $this->assertEquals( 'categories', $json['included'][0]['attributes']['catalog.code'] ); |
|
| 160 | + $client->request('GET', $optJson['meta']['resources']['catalog'], ['include' => 'catalog']); |
|
| 161 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 162 | + $this->assertEquals('categories', $json['included'][0]['attributes']['catalog.code']); |
|
| 163 | 163 | |
| 164 | 164 | // "categories" category |
| 165 | - $client->request( 'GET', $json['included'][0]['links']['self']['href'], ['include' => 'catalog'] ); |
|
| 166 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 167 | - $this->assertEquals( 'cafe', $json['included'][0]['attributes']['catalog.code'] ); |
|
| 165 | + $client->request('GET', $json['included'][0]['links']['self']['href'], ['include' => 'catalog']); |
|
| 166 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 167 | + $this->assertEquals('cafe', $json['included'][0]['attributes']['catalog.code']); |
|
| 168 | 168 | |
| 169 | 169 | // product list for "cafe" category |
| 170 | - $client->request( 'GET', $optJson['meta']['resources']['product'], ['filter' => ['f_catid' => $json['included'][0]['id']]] ); |
|
| 171 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 172 | - $this->assertEquals( 'CNE', $json['data'][0]['attributes']['product.code'] ); |
|
| 170 | + $client->request('GET', $optJson['meta']['resources']['product'], ['filter' => ['f_catid' => $json['included'][0]['id']]]); |
|
| 171 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 172 | + $this->assertEquals('CNE', $json['data'][0]['attributes']['product.code']); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | |
@@ -177,26 +177,26 @@ discard block |
||
| 177 | 177 | { |
| 178 | 178 | $client = static::createClient(); |
| 179 | 179 | |
| 180 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
| 181 | - $options = json_decode( $client->getResponse()->getContent(), true ); |
|
| 182 | - $this->assertGreaterThan( 8, count( $options['meta']['resources'] ) ); |
|
| 180 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
| 181 | + $options = json_decode($client->getResponse()->getContent(), true); |
|
| 182 | + $this->assertGreaterThan(8, count($options['meta']['resources'])); |
|
| 183 | 183 | |
| 184 | 184 | // all available attrbutes |
| 185 | - $client->request( 'GET', $options['meta']['resources']['attribute'] ); |
|
| 186 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 185 | + $client->request('GET', $options['meta']['resources']['attribute']); |
|
| 186 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 187 | 187 | |
| 188 | - foreach( $json['data'] as $entry ) |
|
| 188 | + foreach ($json['data'] as $entry) |
|
| 189 | 189 | { |
| 190 | - if( $entry['attributes']['attribute.code'] === 'xl' ) |
|
| 190 | + if ($entry['attributes']['attribute.code'] === 'xl') |
|
| 191 | 191 | { |
| 192 | 192 | // products with attrbute "xl" |
| 193 | - $client->request( 'GET', $options['meta']['resources']['product'], ['filter' => ['f_attrid' => $entry['id']]] ); |
|
| 193 | + $client->request('GET', $options['meta']['resources']['product'], ['filter' => ['f_attrid' => $entry['id']]]); |
|
| 194 | 194 | break; |
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 199 | - $this->assertEquals( 2, $json['meta']['total'] ); |
|
| 198 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 199 | + $this->assertEquals(2, $json['meta']['total']); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | |
@@ -204,14 +204,14 @@ discard block |
||
| 204 | 204 | { |
| 205 | 205 | $client = static::createClient(); |
| 206 | 206 | |
| 207 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
| 208 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 209 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
| 207 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
| 208 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 209 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
| 210 | 210 | |
| 211 | 211 | // product list for full text search |
| 212 | - $client->request( 'GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'cappuccino']] ); |
|
| 213 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 214 | - $this->assertEquals( 2, count( $json['data'] ) ); |
|
| 212 | + $client->request('GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'cappuccino']]); |
|
| 213 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 214 | + $this->assertEquals(2, count($json['data'])); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | |
@@ -219,23 +219,23 @@ discard block |
||
| 219 | 219 | { |
| 220 | 220 | $client = static::createClient(); |
| 221 | 221 | |
| 222 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
| 223 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 224 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
| 222 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
| 223 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 224 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
| 225 | 225 | |
| 226 | 226 | // get empty basket |
| 227 | - $client->request( 'GET', $json['meta']['resources']['basket'] ); |
|
| 228 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 229 | - $this->assertEquals( 'basket', $json['data']['type'] ); |
|
| 227 | + $client->request('GET', $json['meta']['resources']['basket']); |
|
| 228 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 229 | + $this->assertEquals('basket', $json['data']['type']); |
|
| 230 | 230 | |
| 231 | 231 | $content = '{"data": {"id": "delivery", "attributes": {"order.base.address.firstname": "test"}}}'; |
| 232 | - $client->request( 'POST', $json['links']['basket/address']['href'], [], [], [], $content ); |
|
| 233 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 234 | - $this->assertEquals( 'basket/address', $json['included'][0]['type'] ); |
|
| 232 | + $client->request('POST', $json['links']['basket/address']['href'], [], [], [], $content); |
|
| 233 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 234 | + $this->assertEquals('basket/address', $json['included'][0]['type']); |
|
| 235 | 235 | |
| 236 | - $client->request( 'DELETE', $json['included'][0]['links']['self']['href'] ); |
|
| 237 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 238 | - $this->assertEquals( 0, count( $json['included'] ) ); |
|
| 236 | + $client->request('DELETE', $json['included'][0]['links']['self']['href']); |
|
| 237 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 238 | + $this->assertEquals(0, count($json['included'])); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | |
@@ -243,31 +243,31 @@ discard block |
||
| 243 | 243 | { |
| 244 | 244 | $client = static::createClient(); |
| 245 | 245 | |
| 246 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
| 247 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 248 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
| 246 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
| 247 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 248 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
| 249 | 249 | |
| 250 | 250 | // product for code "CNC" |
| 251 | - $client->request( 'GET', $json['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]] ); |
|
| 252 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 253 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
| 251 | + $client->request('GET', $json['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]]); |
|
| 252 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 253 | + $this->assertEquals(1, count($json['data'])); |
|
| 254 | 254 | |
| 255 | 255 | // add product "CNC" as prerequisite |
| 256 | - $content = '{"data": {"attributes": {"product.id": ' . $json['data'][0]['id'] . '}}}'; |
|
| 257 | - $client->request( 'POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content ); |
|
| 258 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 259 | - $this->assertEquals( 'basket/product', $json['included'][0]['type'] ); |
|
| 256 | + $content = '{"data": {"attributes": {"product.id": '.$json['data'][0]['id'].'}}}'; |
|
| 257 | + $client->request('POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content); |
|
| 258 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 259 | + $this->assertEquals('basket/product', $json['included'][0]['type']); |
|
| 260 | 260 | |
| 261 | 261 | // add coupon "GHIJ" |
| 262 | 262 | $content = '{"data": {"id": "GHIJ"}}'; |
| 263 | - $client->request( 'POST', $json['links']['basket/coupon']['href'], [], [], [], $content ); |
|
| 264 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 265 | - $this->assertEquals( 'basket/coupon', $json['included'][2]['type'] ); |
|
| 263 | + $client->request('POST', $json['links']['basket/coupon']['href'], [], [], [], $content); |
|
| 264 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 265 | + $this->assertEquals('basket/coupon', $json['included'][2]['type']); |
|
| 266 | 266 | |
| 267 | 267 | // remove coupon "GHIJ" again |
| 268 | - $client->request( 'DELETE', $json['included'][2]['links']['self']['href'] ); |
|
| 269 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 270 | - $this->assertEquals( 1, count( $json['included'] ) ); |
|
| 268 | + $client->request('DELETE', $json['included'][2]['links']['self']['href']); |
|
| 269 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 270 | + $this->assertEquals(1, count($json['included'])); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | |
@@ -275,28 +275,28 @@ discard block |
||
| 275 | 275 | { |
| 276 | 276 | $client = static::createClient(); |
| 277 | 277 | |
| 278 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
| 279 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 280 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
| 278 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
| 279 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 280 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
| 281 | 281 | |
| 282 | 282 | // product for code "CNC" |
| 283 | - $client->request( 'GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'ABCD']] ); |
|
| 284 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 285 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
| 283 | + $client->request('GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'ABCD']]); |
|
| 284 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 285 | + $this->assertEquals(1, count($json['data'])); |
|
| 286 | 286 | |
| 287 | - $content = '{"data": {"attributes": {"product.id": ' . $json['data'][0]['id'] . '}}}'; |
|
| 288 | - $client->request( 'POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content ); |
|
| 289 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 290 | - $this->assertEquals( 'basket/product', $json['included'][0]['type'] ); |
|
| 287 | + $content = '{"data": {"attributes": {"product.id": '.$json['data'][0]['id'].'}}}'; |
|
| 288 | + $client->request('POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content); |
|
| 289 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 290 | + $this->assertEquals('basket/product', $json['included'][0]['type']); |
|
| 291 | 291 | |
| 292 | 292 | $content = '{"data": {"attributes": {"quantity": 2}}}'; |
| 293 | - $client->request( 'PATCH', $json['included'][0]['links']['self']['href'], [], [], [], $content ); |
|
| 294 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 295 | - $this->assertEquals( 2, $json['included'][0]['attributes']['order.base.product.quantity'] ); |
|
| 293 | + $client->request('PATCH', $json['included'][0]['links']['self']['href'], [], [], [], $content); |
|
| 294 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 295 | + $this->assertEquals(2, $json['included'][0]['attributes']['order.base.product.quantity']); |
|
| 296 | 296 | |
| 297 | - $client->request( 'DELETE', $json['included'][0]['links']['self']['href'] ); |
|
| 298 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 299 | - $this->assertEquals( 0, count( $json['included'] ) ); |
|
| 297 | + $client->request('DELETE', $json['included'][0]['links']['self']['href']); |
|
| 298 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 299 | + $this->assertEquals(0, count($json['included'])); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | |
@@ -304,14 +304,14 @@ discard block |
||
| 304 | 304 | { |
| 305 | 305 | $client = static::createClient(); |
| 306 | 306 | |
| 307 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
| 308 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 309 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
| 307 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
| 308 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 309 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
| 310 | 310 | |
| 311 | 311 | // payment services |
| 312 | - $client->request( 'GET', $json['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']] ); |
|
| 313 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 314 | - $this->assertEquals( 3, count( $json['data'] ) ); |
|
| 312 | + $client->request('GET', $json['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']]); |
|
| 313 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 314 | + $this->assertEquals(3, count($json['data'])); |
|
| 315 | 315 | |
| 316 | 316 | $content = ['data' => ['id' => 'payment', 'attributes' => [ |
| 317 | 317 | 'service.id' => $json['data'][1]['id'], |
@@ -320,15 +320,15 @@ discard block |
||
| 320 | 320 | 'directdebit.bankcode' => 'ABCDEFGH', |
| 321 | 321 | 'directdebit.bankname' => 'test bank', |
| 322 | 322 | ]]]; |
| 323 | - $client->request( 'POST', $json['data'][1]['links']['basket/service']['href'], [], [], [], json_encode( $content ) ); |
|
| 324 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 325 | - $this->assertEquals( 'basket/service', $json['included'][0]['type'] ); |
|
| 326 | - $this->assertEquals( 'directdebit-test', $json['included'][0]['attributes']['order.base.service.code'] ); |
|
| 327 | - $this->assertEquals( 5, count( $json['included'][0]['attributes']['attribute'] ) ); |
|
| 328 | - |
|
| 329 | - $client->request( 'DELETE', $json['included'][0]['links']['self']['href'] ); |
|
| 330 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 331 | - $this->assertEquals( 0, count( $json['included'] ) ); |
|
| 323 | + $client->request('POST', $json['data'][1]['links']['basket/service']['href'], [], [], [], json_encode($content)); |
|
| 324 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 325 | + $this->assertEquals('basket/service', $json['included'][0]['type']); |
|
| 326 | + $this->assertEquals('directdebit-test', $json['included'][0]['attributes']['order.base.service.code']); |
|
| 327 | + $this->assertEquals(5, count($json['included'][0]['attributes']['attribute'])); |
|
| 328 | + |
|
| 329 | + $client->request('DELETE', $json['included'][0]['links']['self']['href']); |
|
| 330 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 331 | + $this->assertEquals(0, count($json['included'])); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | |
@@ -337,17 +337,17 @@ discard block |
||
| 337 | 337 | $client = static::createClient(array(), array( |
| 338 | 338 | 'PHP_AUTH_USER' => 'UTC001', |
| 339 | 339 | 'PHP_AUTH_PW' => 'unittest', |
| 340 | - ) ); |
|
| 340 | + )); |
|
| 341 | 341 | |
| 342 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/customer', [] ); |
|
| 342 | + $client->request('GET', '/unittest/de/EUR/jsonapi/customer', []); |
|
| 343 | 343 | $response = $client->getResponse(); |
| 344 | 344 | |
| 345 | - $json = json_decode( $response->getContent(), true ); |
|
| 345 | + $json = json_decode($response->getContent(), true); |
|
| 346 | 346 | |
| 347 | - $this->assertNotNull( $json ); |
|
| 348 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 349 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
| 350 | - $this->assertEquals( 4, count( $json['data'] ) ); |
|
| 347 | + $this->assertNotNull($json); |
|
| 348 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 349 | + $this->assertEquals(1, $json['meta']['total']); |
|
| 350 | + $this->assertEquals(4, count($json['data'])); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | |
@@ -356,22 +356,22 @@ discard block |
||
| 356 | 356 | $client = static::createClient(array(), array( |
| 357 | 357 | 'PHP_AUTH_USER' => 'UTC001', |
| 358 | 358 | 'PHP_AUTH_PW' => 'unittest', |
| 359 | - ) ); |
|
| 359 | + )); |
|
| 360 | 360 | |
| 361 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/customer', [] ); |
|
| 361 | + $client->request('GET', '/unittest/de/EUR/jsonapi/customer', []); |
|
| 362 | 362 | $response = $client->getResponse(); |
| 363 | 363 | |
| 364 | - $json = json_decode( $response->getContent(), true ); |
|
| 364 | + $json = json_decode($response->getContent(), true); |
|
| 365 | 365 | |
| 366 | - $client->request( 'GET', $json['links']['customer/address']['href'], [] ); |
|
| 366 | + $client->request('GET', $json['links']['customer/address']['href'], []); |
|
| 367 | 367 | $response = $client->getResponse(); |
| 368 | 368 | |
| 369 | - $json = json_decode( $response->getContent(), true ); |
|
| 369 | + $json = json_decode($response->getContent(), true); |
|
| 370 | 370 | |
| 371 | - $this->assertNotNull( $json ); |
|
| 372 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 373 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
| 374 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
| 371 | + $this->assertNotNull($json); |
|
| 372 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 373 | + $this->assertEquals(1, $json['meta']['total']); |
|
| 374 | + $this->assertEquals(1, count($json['data'])); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | |
@@ -380,17 +380,17 @@ discard block |
||
| 380 | 380 | $client = static::createClient(array(), array( |
| 381 | 381 | 'PHP_AUTH_USER' => 'UTC001', |
| 382 | 382 | 'PHP_AUTH_PW' => 'unittest', |
| 383 | - ) ); |
|
| 383 | + )); |
|
| 384 | 384 | |
| 385 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/order', [] ); |
|
| 385 | + $client->request('GET', '/unittest/de/EUR/jsonapi/order', []); |
|
| 386 | 386 | $response = $client->getResponse(); |
| 387 | 387 | |
| 388 | - $json = json_decode( $response->getContent(), true ); |
|
| 388 | + $json = json_decode($response->getContent(), true); |
|
| 389 | 389 | |
| 390 | - $this->assertNotNull( $json ); |
|
| 391 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 392 | - $this->assertEquals( 5, $json['meta']['total'] ); |
|
| 393 | - $this->assertEquals( 5, count( $json['data'] ) ); |
|
| 390 | + $this->assertNotNull($json); |
|
| 391 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 392 | + $this->assertEquals(5, $json['meta']['total']); |
|
| 393 | + $this->assertEquals(5, count($json['data'])); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | |
@@ -398,63 +398,63 @@ discard block |
||
| 398 | 398 | { |
| 399 | 399 | $client = static::createClient(); |
| 400 | 400 | |
| 401 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
| 402 | - $optJson = json_decode( $client->getResponse()->getContent(), true ); |
|
| 403 | - $this->assertGreaterThan( 8, count( $optJson['meta']['resources'] ) ); |
|
| 401 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
| 402 | + $optJson = json_decode($client->getResponse()->getContent(), true); |
|
| 403 | + $this->assertGreaterThan(8, count($optJson['meta']['resources'])); |
|
| 404 | 404 | |
| 405 | 405 | // product for code "CNC" |
| 406 | - $client->request( 'GET', $optJson['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]] ); |
|
| 407 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 408 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
| 406 | + $client->request('GET', $optJson['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]]); |
|
| 407 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 408 | + $this->assertEquals(1, count($json['data'])); |
|
| 409 | 409 | |
| 410 | 410 | // add product "CNC" |
| 411 | - $content = '{"data": {"attributes": {"product.id": ' . $json['data'][0]['id'] . '}}}'; |
|
| 412 | - $client->request( 'POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content ); |
|
| 413 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 414 | - $this->assertEquals( 'basket/product', $json['included'][0]['type'] ); |
|
| 411 | + $content = '{"data": {"attributes": {"product.id": '.$json['data'][0]['id'].'}}}'; |
|
| 412 | + $client->request('POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content); |
|
| 413 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 414 | + $this->assertEquals('basket/product', $json['included'][0]['type']); |
|
| 415 | 415 | |
| 416 | 416 | // delivery services |
| 417 | - $client->request( 'GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'delivery']] ); |
|
| 418 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 419 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
| 417 | + $client->request('GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'delivery']]); |
|
| 418 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 419 | + $this->assertEquals(1, count($json['data'])); |
|
| 420 | 420 | |
| 421 | 421 | // add delivery service |
| 422 | - $content = '{"data": {"id": "delivery", "attributes": {"service.id": ' . $json['data'][0]['id'] . '}}}'; |
|
| 423 | - $client->request( 'POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content ); |
|
| 424 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 425 | - $this->assertEquals( 'basket/service', $json['included'][1]['type'] ); |
|
| 422 | + $content = '{"data": {"id": "delivery", "attributes": {"service.id": '.$json['data'][0]['id'].'}}}'; |
|
| 423 | + $client->request('POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content); |
|
| 424 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 425 | + $this->assertEquals('basket/service', $json['included'][1]['type']); |
|
| 426 | 426 | |
| 427 | 427 | // payment services |
| 428 | - $client->request( 'GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']] ); |
|
| 429 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 430 | - $this->assertEquals( 3, count( $json['data'] ) ); |
|
| 428 | + $client->request('GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']]); |
|
| 429 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 430 | + $this->assertEquals(3, count($json['data'])); |
|
| 431 | 431 | |
| 432 | 432 | // add payment service |
| 433 | - $content = '{"data": {"id": "payment", "attributes": {"service.id": ' . $json['data'][0]['id'] . '}}}'; |
|
| 434 | - $client->request( 'POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content ); |
|
| 435 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 436 | - $this->assertEquals( 'basket/service', $json['included'][2]['type'] ); |
|
| 433 | + $content = '{"data": {"id": "payment", "attributes": {"service.id": '.$json['data'][0]['id'].'}}}'; |
|
| 434 | + $client->request('POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content); |
|
| 435 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 436 | + $this->assertEquals('basket/service', $json['included'][2]['type']); |
|
| 437 | 437 | |
| 438 | 438 | // add address |
| 439 | 439 | $content = '{"data": {"id": "payment", "attributes": {"order.base.address.firstname": "test"}}}'; |
| 440 | - $client->request( 'POST', $json['links']['basket/address']['href'], [], [], [], $content ); |
|
| 441 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 442 | - $this->assertEquals( 'basket/address', $json['included'][3]['type'] ); |
|
| 440 | + $client->request('POST', $json['links']['basket/address']['href'], [], [], [], $content); |
|
| 441 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 442 | + $this->assertEquals('basket/address', $json['included'][3]['type']); |
|
| 443 | 443 | |
| 444 | 444 | // store basket |
| 445 | - $client->request( 'POST', $json['data']['links']['self']['href'] ); |
|
| 446 | - $basketJson = json_decode( $client->getResponse()->getContent(), true ); |
|
| 447 | - $this->assertEquals( true, ctype_digit( $basketJson['data']['id'] ) ); |
|
| 445 | + $client->request('POST', $json['data']['links']['self']['href']); |
|
| 446 | + $basketJson = json_decode($client->getResponse()->getContent(), true); |
|
| 447 | + $this->assertEquals(true, ctype_digit($basketJson['data']['id'])); |
|
| 448 | 448 | |
| 449 | 449 | // add order |
| 450 | - $content = '{"data": {"attributes": {"order.baseid": ' . $basketJson['data']['id'] . '}}}'; |
|
| 451 | - $client->request( 'POST', $basketJson['links']['order']['href'], [], [], [], $content ); |
|
| 452 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 453 | - $this->assertEquals( true, ctype_digit( $json['data']['id'] ) ); |
|
| 450 | + $content = '{"data": {"attributes": {"order.baseid": '.$basketJson['data']['id'].'}}}'; |
|
| 451 | + $client->request('POST', $basketJson['links']['order']['href'], [], [], [], $content); |
|
| 452 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 453 | + $this->assertEquals(true, ctype_digit($json['data']['id'])); |
|
| 454 | 454 | |
| 455 | 455 | |
| 456 | 456 | // delete created order |
| 457 | - $context = static::$kernel->getContainer()->get( 'aimeos.context' )->get(); |
|
| 458 | - \Aimeos\MShop::create( $context, 'order/base' )->deleteItem( $basketJson['data']['id'] ); |
|
| 457 | + $context = static::$kernel->getContainer()->get('aimeos.context')->get(); |
|
| 458 | + \Aimeos\MShop::create($context, 'order/base')->deleteItem($basketJson['data']['id']); |
|
| 459 | 459 | } |
| 460 | 460 | } |