Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
Table example
foreach
(
$bundles
as
$bundle
)
{
$extension
=
$bundle
->
getContainerExtension
(
)
;
$rows
[
]
=
[
$bundle
->
getName
(
)
,
$extension
?
$extension
->
getAlias
(
)
: ''
]
;
}
if
(
$output
instanceof StyleInterface
)
{
$output
->
title
(
$title
)
;
$output
->
table
(
$headers
,
$rows
)
;
}
else
{
$output
->
writeln
(
$title
)
;
$table
=
new
Table
(
$output
)
;
$table
->
setHeaders
(
$headers
)
->
setRows
(
$rows
)
->
render
(
)
;
}
}
protected
function
listNonBundleExtensions
(
OutputInterface|StyleInterface
$output
)
: void
{
$title
= 'Available registered non-bundle extension aliases';
$headers
=
[
'Extension alias'
]
;
$rows
=
[
]
;
$kernel
=
$this
->
getApplication
(
)
->
getKernel
(
)
;
/** * @param array|string $field * * @return array|string|null */
protected
function
_alterTable
(
string
$alterType
, string
$table
,
$field
)
{
switch
(
$alterType
)
{
case
'DROP':
$sqlTable
=
new
Table
(
$this
->db,
$this
)
;
$sqlTable
->
fromTable
(
$table
)
->
dropColumn
(
$field
)
->
run
(
)
;
return
'';
case
'CHANGE':
(
new
Table
(
$this
->db,
$this
)
)
->
fromTable
(
$table
)
->
modifyColumn
(
$field
)
if
(
!
$rows
)
{
$io
->
section
(
$title
)
;
$io
->
text
(
'No Serializer data were found for this class.'
)
;
return
;
}
$io
->
section
(
$title
)
;
$table
=
new
Table
(
$output
)
;
$table
->
setHeaders
(
[
'Property', 'Options'
]
)
;
$table
->
setRows
(
$rows
)
;
$table
->
render
(
)
;
}
/** * @return array<string, array<string, mixed>> */
private
function
getAttributesData
(
ClassMetadataInterface
$classMetadata
)
: array
{
$data
=
[
]
;
return
;
}
$io
->
section
(
$title
)
;
$io
->
text
(
'No validators were found for this class.'
)
;
return
;
}
$io
->
section
(
$title
)
;
$table
=
new
Table
(
$output
)
;
$table
->
setHeaders
(
[
'Property', 'Name', 'Groups', 'Options'
]
)
;
$table
->
setRows
(
$rows
)
;
$table
->
setColumnMaxWidth
(
3, 80
)
;
$table
->
render
(
)
;
}
private
function
getClassConstraintsData
(
ClassMetadataInterface
$classMetadata
)
: iterable
{
foreach
(
$classMetadata
->
getConstraints
(
)
as
$constraint
)
{
yield
[
'class' =>
$constraint
::
class
,
$otherTransport
=
$this
->
createMock
(
TransportInterface::
class
)
;
$otherTransport
->
expects
(
$this
->
never
(
)
)
->
method
(
$this
->
anything
(
)
)
;
$subscriber
=
new
MessengerTransportDoctrineSchemaListener
(
[
$doctrineTransport
,
$otherTransport
]
)
;
$subscriber
->
postGenerateSchema
(
$event
)
;
}
public
function
testOnSchemaCreateTable
(
)
{
$platform
=
$this
->
createMock
(
AbstractPlatform::
class
)
;
$table
=
new
Table
(
'queue_table'
)
;
$event
=
new
SchemaCreateTableEventArgs
(
$table
,
[
]
,
[
]
,
$platform
)
;
$otherTransport
=
$this
->
createMock
(
TransportInterface::
class
)
;
$otherTransport
->
expects
(
$this
->
never
(
)
)
->
method
(
$this
->
anything
(
)
)
;
$doctrineTransport
=
$this
->
createMock
(
DoctrineTransport::
class
)
;
$doctrineTransport
->
expects
(
$this
->
once
(
)
)
->
method
(
'getExtraSetupSqlForTable'
)
->
with
(
$table
)
->
willReturn
(
[
'ALTER TABLE pizza ADD COLUMN extra_cheese boolean'
]
)
;
if
(
$showControllers
)
{
$row
[
]
=
$controller
?
$this
->
formatControllerLink
(
$controller
,
$this
->
formatCallable
(
$controller
)
,
$options
[
'container'
]
?? null
)
: '';
}
$tableRows
[
]
=
$row
;
}
if
(
isset
(
$options
[
'output'
]
)
)
{
$options
[
'output'
]
->
table
(
$tableHeaders
,
$tableRows
)
;
}
else
{
$table
=
new
Table
(
$this
->
getOutput
(
)
)
;
$table
->
setHeaders
(
$tableHeaders
)
->
setRows
(
$tableRows
)
;
$table
->
render
(
)
;
}
}
protected
function
describeRoute
(
Route
$route
, array
$options
=
[
]
)
: void
{
$defaults
=
$route
->
getDefaults
(
)
;
if
(
isset
(
$defaults
[
'_controller'
]
)
)
{
$defaults
[
'_controller'
]
=
$this
->
formatControllerLink
(
$defaults
[
'_controller'
]
,
$this
->
formatCallable
(
$defaults
[
'_controller'
]
)
,
$options
[
'container'
]
?? null
)
;
}
protected
function
tearDown
(
)
: void
{
unset
(
$this
->stream
)
;
}
/** * @dataProvider renderProvider */
public
function
testRender
(
$headers
,
$rows
,
$style
,
$expected
,
$decorated
= false
)
{
$table
=
new
Table
(
$output
=
$this
->
getOutputStream
(
$decorated
)
)
;
$table
->
setHeaders
(
$headers
)
->
setRows
(
$rows
)
->
setStyle
(
$style
)
;
$table
->
render
(
)
;
$this
->
assertEquals
(
$expected
,
$this
->
getOutputContent
(
$output
)
)
;
}
/** * @dataProvider renderProvider */
return
;
}
$io
->
section
(
$title
)
;
$io
->
text
(
'No validators were found for this class.'
)
;
return
;
}
$io
->
section
(
$title
)
;
$table
=
new
Table
(
$output
)
;
$table
->
setHeaders
(
[
'Property', 'Name', 'Groups', 'Options'
]
)
;
$table
->
setRows
(
$rows
)
;
$table
->
setColumnMaxWidth
(
3, 80
)
;
$table
->
render
(
)
;
}
private
function
getClassConstraintsData
(
ClassMetadataInterface
$classMetadata
)
: iterable
{
foreach
(
$classMetadata
->
getConstraints
(
)
as
$constraint
)
{
yield
[
'class' =>
$constraint
::
class
,
public
function
getErrorStyle
(
)
: self
{
return
new
self
(
$this
->input,
$this
->
getErrorOutput
(
)
)
;
}
public
function
createTable
(
)
: Table
{
$output
=
$this
->output instanceof ConsoleOutputInterface ?
$this
->output->
section
(
)
:
$this
->output;
$style
=
clone
Table::
getStyleDefinition
(
'symfony-style-guide'
)
;
$style
->
setCellHeaderFormat
(
'<info>%s</info>'
)
;
return
(
new
Table
(
$output
)
)
->
setStyle
(
$style
)
;
}
private
function
getProgressBar
(
)
: ProgressBar
{
return
$this
->progressBar
??
throw
new
RuntimeException
(
'The ProgressBar is not started.'
)
;
}
private
function
autoPrependBlock
(
)
: void
{
$chars
=
substr
(
str_replace
(
\PHP_EOL, "\n",
$this
->bufferedOutput->
fetch
(
)
)
, -2
)
;
$connection
->
get
(
)
;
$this
->
assertSame
(
2,
$wrappedConnection
->
countNotifyCalls
(
)
)
;
}
public
function
testGetExtraSetupSql
(
)
{
$driverConnection
=
$this
->
createMock
(
\Doctrine\DBAL\Connection::
class
)
;
$driverConnection
->
method
(
'executeStatement'
)
->
willReturn
(
1
)
;
$connection
=
new
PostgreSqlConnection
(
[
'table_name' => 'queue_table'
]
,
$driverConnection
)
;
$table
=
new
Table
(
'queue_table'
)
;
$table
->
addOption
(
'_symfony_messenger_table_name', 'queue_table'
)
;
$sql
=
implode
(
"\n",
$connection
->
getExtraSetupSqlForTable
(
$table
)
)
;
$this
->
assertStringContainsString
(
'CREATE TRIGGER',
$sql
)
;
// We MUST NOT use transaction, that will mess with the PDO in PHP 8
$this
->
assertStringNotContainsString
(
'BEGIN;',
$sql
)
;
$this
->
assertStringNotContainsString
(
'COMMIT;',
$sql
)
;
}
public
function
testTransformTableNameWithSchemaToValidProcedureName
(
)
{
if
(
!
$rows
)
{
$io
->
section
(
$title
)
;
$io
->
text
(
'No Serializer data were found for this class.'
)
;
return
;
}
$io
->
section
(
$title
)
;
$table
=
new
Table
(
$output
)
;
$table
->
setHeaders
(
[
'Property', 'Options'
]
)
;
$table
->
setRows
(
$rows
)
;
$table
->
render
(
)
;
}
/** * @return array<string, array<string, mixed>> */
private
function
getAttributesData
(
ClassMetadataInterface
$classMetadata
)
: array
{
$data
=
[
]
;
public
function
getErrorStyle
(
)
: self
{
return
new
self
(
$this
->input,
$this
->
getErrorOutput
(
)
)
;
}
public
function
createTable
(
)
: Table
{
$output
=
$this
->output instanceof ConsoleOutputInterface ?
$this
->output->
section
(
)
:
$this
->output;
$style
=
clone
Table::
getStyleDefinition
(
'symfony-style-guide'
)
;
$style
->
setCellHeaderFormat
(
'<info>%s</info>'
)
;
return
(
new
Table
(
$output
)
)
->
setStyle
(
$style
)
;
}
private
function
getProgressBar
(
)
: ProgressBar
{
return
$this
->progressBar
??
throw
new
RuntimeException
(
'The ProgressBar is not started.'
)
;
}
private
function
autoPrependBlock
(
)
: void
{
$chars
=
substr
(
str_replace
(
\PHP_EOL, "\n",
$this
->bufferedOutput->
fetch
(
)
)
, -2
)
;